ChesterS
ChesterS
FFilament
Created by ChesterS on 1/10/2025 in #❓┊help
Is it possible to suppress a notification popup
I have a notification that is sent to another user. Something like this
$notification = Notification::make()
->title(__('New message'))
->body($message->content)
->actions([
NotificationAction::make('view')
->button()
->url('some_url'),
]);

$notification->sendToDatabase($recipient);

$notification->broadcast($recipient);

event(new DatabaseNotificationsSent($recipient));
$notification = Notification::make()
->title(__('New message'))
->body($message->content)
->actions([
NotificationAction::make('view')
->button()
->url('some_url'),
]);

$notification->sendToDatabase($recipient);

$notification->broadcast($recipient);

event(new DatabaseNotificationsSent($recipient));
However, if the $recipient is already at some_url, I don't want them to actually show the popup. Is there a way to check in the client if the current user is in that page and suppress the notification? What I mean is, if I'm the recipient, can I prevent the notification somehow? (I obviously can't know at the time the notification is sent, only when it's received) Hope this makes sense. Any ideas welcome
1 replies
FFilament
Created by ChesterS on 12/5/2024 in #❓┊help
Form trying to update a field that is not in the form
This is my form (simplified)
Textarea::make('description'),
Toggle::make('is_active'),
Textarea::make('description'),
Toggle::make('is_active'),
When I try to save it, the query also includes a field that is not in the form
update
`some_table`
set
`description` = ?,
`is_active` = 1,
`alert` = 0, <-???
where
`id` = 2
update
`some_table`
set
`description` = ?,
`is_active` = 1,
`alert` = 0, <-???
where
`id` = 2
As you can see, there is an extra alert field there. Just to be clear, the tables does have an alert column, but why is the form trying to update it if it's not in the schema?
17 replies
FFilament
Created by ChesterS on 11/1/2024 in #❓┊help
Is it possible to make a custom action behave/look like as submit button?
Sorry if the title makes no sense. When you upload files to a filament form, the 'submit' button changes (The label changes to 'Uploading files...', the button gets disabled and a loading indicator is added) Is it possible to have the same behaviour with a custom action? The only thing I managed to do is disable the button with a custom attribute
public function doSomethingAction(): Action
{
return Action::make('doSomethingAction')
->label('Do something')
->extraAttributes([
'wire:loading.attr' => 'disabled',
'x-bind:disabled' => 'isProcessing',
'type' => 'submit',
])
->action(function (array $data) {
....
});
}
public function doSomethingAction(): Action
{
return Action::make('doSomethingAction')
->label('Do something')
->extraAttributes([
'wire:loading.attr' => 'disabled',
'x-bind:disabled' => 'isProcessing',
'type' => 'submit',
])
->action(function (array $data) {
....
});
}
Is there a way to get the rest of the functionality? (change the label, add a loading indicator etc)
4 replies
FFilament
Created by ChesterS on 10/28/2024 in #❓┊help
Save form from a header action
Is it possible to save a form from a header action (or before a header action? Let's say I have the following header actions in an edit form
protected function getHeaderActions(): array {
return [
Action::make('print'),
Action::make('duplicate'),
]
}
protected function getHeaderActions(): array {
return [
Action::make('print'),
Action::make('duplicate'),
]
}
Is there a way to submit the form before any of those actions is executed? Or somehow submit it inside the button action itself? I tried this but it doesn't work
Action::make('test')
->requiresConfirmation()
->action(fn (array $data) => dd($data)), // Data is empty
Action::make('test')
->requiresConfirmation()
->action(fn (array $data) => dd($data)), // Data is empty
Or if there's a way to detect if a form has been changed and then ask for a confirmation to save before proceeding? Any ideas are welcome.
10 replies
FFilament
Created by ChesterS on 10/24/2024 in #❓┊help
Can you access the search state in a create action?
Sorry if the title doesn't make much sense I have a select like this
Select::make('user_id')
->createOptionAction(
fn (Action $action) => $action
->modalWidth('3xl'),
)
->createOptionForm(fn(Select $component) => [
TextInput::make('name')
->default(fn () => $component->getState())
->required(),
])
->createOptionUsing(fn ($state, $data) => dd($state, $data))
->live()
Select::make('user_id')
->createOptionAction(
fn (Action $action) => $action
->modalWidth('3xl'),
)
->createOptionForm(fn(Select $component) => [
TextInput::make('name')
->default(fn () => $component->getState())
->required(),
])
->createOptionUsing(fn ($state, $data) => dd($state, $data))
->live()
Is there a way to access what the user has typed in the select to be used as a default value in the createOptionForm? $component->getState() is null
12 replies
FFilament
Created by ChesterS on 10/16/2024 in #❓┊help
Change widget icon color
No description
9 replies
FFilament
Created by ChesterS on 10/3/2024 in #❓┊help
Resource visible in sidebar even if `viewAny()` returns false
As per title, I have a resource that's only available to certain users. According to the docs here https://filamentphp.com/docs/3.x/panels/resources/getting-started#authorization the link should not be visible if they don't have access to it. However, that's not the case for me. They can still see the link but they get a 403 when trying click on it (as expected) The navigation menu is build 'manually'
->navigation(function (NavigationBuilder $builder): NavigationBuilder {
return $builder
->groups([
NavigationGroup::make('Setup')
->items([
...TeamResource::getNavigationItems(), // Do I need to do anything here?
]),
])
})
->navigation(function (NavigationBuilder $builder): NavigationBuilder {
return $builder
->groups([
NavigationGroup::make('Setup')
->items([
...TeamResource::getNavigationItems(), // Do I need to do anything here?
]),
])
})
(not sure what else I need to provide. The resource itself is as boilerplate as it gets) When I put a breakpoint in the viewAny() call in the policy, it looks like it's never hit. Am I missing something or doing something wrong?
13 replies
FFilament
Created by ChesterS on 9/17/2024 in #❓┊help
Register Filepond Plugin
There is a similar post here : https://discord.com/channels/883083792112300104/1151432989276913674 Is there a way to register a plugin for FileUpload without overriding the whole thing? I've tried all the solutions mentioned in the above thread - except for the suggestion to override the entire file-upload.js file. Here are some of the things I tried.
FilamentAsset::register([
Js::make('filepond-config', __DIR__.'/../../resources/js/filepond-config.js'),
Js::make('filepond-config', Vite::asset('resources/js/filepond-config.js')),
]);

FilamentView::registerRenderHook( PanelsRenderHook::SCRIPTS_AFTER,
fn (): string => Blade::render("@vite('resources/js/filepond-config.js')")
);
FilamentAsset::register([
Js::make('filepond-config', __DIR__.'/../../resources/js/filepond-config.js'),
Js::make('filepond-config', Vite::asset('resources/js/filepond-config.js')),
]);

FilamentView::registerRenderHook( PanelsRenderHook::SCRIPTS_AFTER,
fn (): string => Blade::render("@vite('resources/js/filepond-config.js')")
);
// This is just the latest example. The code is from the FilePond documentation
// https://pqina.nl/filepond/docs/api/plugins/file-rename/
import FilePondPluginFileRename from 'filepond-plugin-file-rename';

window.FilePond.registerPlugin(FilePondPluginFileRename);

document.addEventListener("DOMContentLoaded", function(event) {
window.FilePond.setOptions({
fileRenameFunction: (file) =>
new Promise((resolve) => {
resolve(window.prompt('Enter new filename', file.name));
}),
});
});
// This is just the latest example. The code is from the FilePond documentation
// https://pqina.nl/filepond/docs/api/plugins/file-rename/
import FilePondPluginFileRename from 'filepond-plugin-file-rename';

window.FilePond.registerPlugin(FilePondPluginFileRename);

document.addEventListener("DOMContentLoaded", function(event) {
window.FilePond.setOptions({
fileRenameFunction: (file) =>
new Promise((resolve) => {
resolve(window.prompt('Enter new filename', file.name));
}),
});
});
None of the above work for different reasons (obviously, I may be doing something wrong). One of the problems is that the filepond stuff is loaded only when needed so it's not always available. So, is there a way to install FilePond plugins ? Thank you.
15 replies
FFilament
Created by ChesterS on 8/12/2024 in #❓┊help
Access form data in modal action
I have the following action
Action::make('foo')
->form([
TextInput::make('fooBar')
])
->extraModalFooterActions([
Action::make('bar')
->action(function ($record, array $data) {
// $data is empty here
}),
])
->action(function ($record, array $data) {
// $data is available here because the form is submitted
}),
Action::make('foo')
->form([
TextInput::make('fooBar')
])
->extraModalFooterActions([
Action::make('bar')
->action(function ($record, array $data) {
// $data is empty here
}),
])
->action(function ($record, array $data) {
// $data is available here because the form is submitted
}),
Is there a way to get access to the value of the fooBar field inside Action::make('bar') ?
9 replies
FFilament
Created by ChesterS on 7/24/2024 in #❓┊help
Show Filament notification when database notification is received
Is there a built in way to render/show a Filament notification when a database notification is received? For example let's say I have this code
Notification::make()
->title('Saved successfully')
->sendToDatabase($someUser);

event(new DatabaseNotificationsSent($someUser));
Notification::make()
->title('Saved successfully')
->sendToDatabase($someUser);

event(new DatabaseNotificationsSent($someUser));
Is there a built-in way to actually render that notification when $someUser receives it? So they would see the equivalent of
Notification::make()
->title('Saved successfully')
->send();
Notification::make()
->title('Saved successfully')
->send();
If not, is there a callback or some sort of hook/event that's triggered so I can do this manually? Thank you.
5 replies
FFilament
Created by ChesterS on 7/1/2024 in #❓┊help
URL not working in repeater action?
RepeatableEntry::make('items')
->schema([
TextEntry::make('edit')
->hiddenLabel()
->state('Edit')
->icon('heroicon-m-pencil-square')
->action(
Action::make('edit')
->label('Edit')
->icon('heroicon-m-pencil-square')
->action(fn ($record) => redirect(EditItem::getUrl(['record' => $record]))) // This works
->url(fn ($record) => EditItem::getUrl(['record' => $record])) // This DOESNT for some reason...
),
RepeatableEntry::make('items')
->schema([
TextEntry::make('edit')
->hiddenLabel()
->state('Edit')
->icon('heroicon-m-pencil-square')
->action(
Action::make('edit')
->label('Edit')
->icon('heroicon-m-pencil-square')
->action(fn ($record) => redirect(EditItem::getUrl(['record' => $record]))) // This works
->url(fn ($record) => EditItem::getUrl(['record' => $record])) // This DOESNT for some reason...
),
For some reason, using the url(...) method doeson't work. The generated $wire.target= is empty and as a result throws a console error
Alpine Expression Error: missing name after . operator

Expression: "$wire."

<button class="block" type="button" wire:click="" wire:loading.attr="disabled" wire:target="">
Alpine Expression Error: missing name after . operator

Expression: "$wire."

<button class="block" type="button" wire:click="" wire:loading.attr="disabled" wire:target="">
Am i doing something wrong? The URL is obviously correct since it works when I manually redirect() to it.
2 replies
FFilament
Created by ChesterS on 4/29/2024 in #❓┊help
Vite manifest not found when registering custom asset and deploying to production
I have a weird issue when trying to deploy to production. I have a custom asset loaded using
FilamentAsset::register([
Js::make('echo', Vite::asset('resources/js/echo.js')),
]);
FilamentAsset::register([
Js::make('echo', Vite::asset('resources/js/echo.js')),
]);
However, during composer's post-autoload-dump the following commands are executed
"@php artisan package:discover --ansi",
"@php artisan filament:assets"
"@php artisan package:discover --ansi",
"@php artisan filament:assets"
both of which fail because the Vite manifest hasn't been generated yet. The manifest is generated when I ran npm run build but I can't do that because this fails if I haven't installed the composer dependencies yet. So I'm in this weird catch-22 where the composer step fails because I can't build the Vite manifest, and I can't build the Vite manifest because the composer step fails. Removing the FillamentAsset::register... code solves the issue but it's obviously not a solution so I wonder if I'm missing something. I use Forge/Envoyer for the deployments so most steps are vanilla Envoyer stuff. All of it worked untill I wanted to load a custom asset. The manifest is not commited into the repo BTW. Am I supposed to commit it?
35 replies
FFilament
Created by ChesterS on 4/24/2024 in #❓┊help
`requiresConfirmation(false)` still shows confirmation dialog for Delete action
I have the following table action
Actions\DeleteAction::make('delete'))
->icon('heroicon-o-check')
->iconButton()
->requiresConfirmation(false),
Actions\DeleteAction::make('delete'))
->icon('heroicon-o-check')
->iconButton()
->requiresConfirmation(false),
However, I'm still getting a generic confirmation dialog when I click the button. Am I missing something?
Laravel 10.48.8
Filament v3.2.71
Livewire v3.4.10
Laravel 10.48.8
Filament v3.2.71
Livewire v3.4.10
2 replies
FFilament
Created by ChesterS on 4/3/2024 in #❓┊help
Enable Echo.js without breaking Hot Reload
Ok I'm at my wit's end here... I know this is probably not strictly Filament related, but maybe there's a JS wizard here that can help I'm trying to enable broadcasting. Here are the relevant files
// echo.js
import Echo from 'laravel-echo';
import Pusher from 'pusher-js';

window.Pusher = Pusher;

window.Echo = new Echo({
broadcaster: 'reverb',
...
enabledTransports: ['ws', 'wss'],
});
// echo.js
import Echo from 'laravel-echo';
import Pusher from 'pusher-js';

window.Pusher = Pusher;

window.Echo = new Echo({
broadcaster: 'reverb',
...
enabledTransports: ['ws', 'wss'],
});
// AppServiceProvider.php
FilamentAsset::register([
Js::make('echo', Vite::asset('resources/js/echo.js')),
]);
// AppServiceProvider.php
FilamentAsset::register([
Js::make('echo', Vite::asset('resources/js/echo.js')),
]);
//vite.config.js
export default defineConfig({
plugins: [
laravel({
input: [
'resources/css/app.css',
'resources/js/app.js',
'resources/js/echo.js',
'resources/css/filament/theme.css',
],
}),
],

});
//vite.config.js
export default defineConfig({
plugins: [
laravel({
input: [
'resources/css/app.css',
'resources/js/app.js',
'resources/js/echo.js',
'resources/css/filament/theme.css',
],
}),
],

});
As you can see, most of the code is boilerplate. It works when I run npm run build , but when I run npm run dev I get the following error.
Uncaught SyntaxError: import.meta may only appear in a module
Uncaught SyntaxError: import.meta may only appear in a module
in firefox and
Uncaught SyntaxError: Cannot use 'import.meta' outside a module
Uncaught SyntaxError: Cannot use 'import.meta' outside a module
inside the echo.js file
import.meta.env = {"VITE_PUSHER_APP_KEY":"","VITE ....
import.meta.env = {"VITE_PUSHER_APP_KEY":"","VITE ....
Has anyone run into something similar? Any suggestions? Googling for this error doesn't get me anything useful.
5 replies
FFilament
Created by ChesterS on 4/1/2024 in #❓┊help
Load custom component inside action modal
Ok I think I'm missing something obvious here, but is there a way to load a custom Livewire component inside a modal action? Here's an example of what I've tried
use Filament\Infolists\Components\Actions\Action;

Action::make('something')
// ->modalContent(view('livewire.my-modal')) // This doesn't work either since it's just the view
->livewire(new MyCustomComponent())
use Filament\Infolists\Components\Actions\Action;

Action::make('something')
// ->modalContent(view('livewire.my-modal')) // This doesn't work either since it's just the view
->livewire(new MyCustomComponent())
but it doesn't work (the modal is empty) This is what my component looks like
class MyCustomComponent extends Component implements HasActions, HasForms, HasTable
{
use HasTabs;
use InteractsWithActions;
use InteractsWithForms;
use InteractsWithTable {
makeTable as makeBaseTable;
}

public function mount(): void
{
...
}

public function render(): View
{
return view('livewire.my-modal');
}
}
class MyCustomComponent extends Component implements HasActions, HasForms, HasTable
{
use HasTabs;
use InteractsWithActions;
use InteractsWithForms;
use InteractsWithTable {
makeTable as makeBaseTable;
}

public function mount(): void
{
...
}

public function render(): View
{
return view('livewire.my-modal');
}
}
9 replies
FFilament
Created by ChesterS on 2/27/2024 in #❓┊help
Create action with relation throws error
Sorry for the vague title I have the following action
Actions\Action::make('createUser')
->form([
TextInput::make('email'),
Select::make('roles')
->multiple()
->searchable(false)
->preload()
->options(Roles::options()) // This is an enum
->getOptionLabelFromRecordUsing(fn (Role $record) => Roles::from($record->name)->getLabel())
->relationship('roles', 'name'),
])

->action(function ($record, array $data) {
$record->user()->create($data);
})
Actions\Action::make('createUser')
->form([
TextInput::make('email'),
Select::make('roles')
->multiple()
->searchable(false)
->preload()
->options(Roles::options()) // This is an enum
->getOptionLabelFromRecordUsing(fn (Role $record) => Roles::from($record->name)->getLabel())
->relationship('roles', 'name'),
])

->action(function ($record, array $data) {
$record->user()->create($data);
})
When I click on the button, I get the following error
Filament\Support\Services\RelationshipJoiner::prepareQueryForNoConstraints(): Argument #1 ($relationship) must be of type Illuminate\Database\Eloquent\Relations\Relation, null given, called in /var/www/.../vendor/filament/forms/src/Components/Select.php on line 765
Filament\Support\Services\RelationshipJoiner::prepareQueryForNoConstraints(): Argument #1 ($relationship) must be of type Illuminate\Database\Eloquent\Relations\Relation, null given, called in /var/www/.../vendor/filament/forms/src/Components/Select.php on line 765
This is the exact same form I use in the UserResource and it works when creating a new user, but for some reason doesn't work when doing it outside the resource. I tried adding
->model(User::class)
->model(User::class)
and some other things but nothing worked. What am I doing wrong?
5 replies
FFilament
Created by ChesterS on 2/2/2024 in #❓┊help
Refresh Filament component from a custom one
I have the following infolist
return $infolist->schema([
...
Section::make()
->schema([
Livewire::make(MyCustomComponent::class)
]),
]);
return $infolist->schema([
...
Section::make()
->schema([
Livewire::make(MyCustomComponent::class)
]),
]);
Is there a way to trigger the infolist to update from inside MyCustomComponent? I can listen for an event inside the my filament ViewRecord class, but I'm not sure how to trigger the actual update/refresh. I'd rather avoid a full page reload. Ideally, I would have the same behaviour actions have (eg only the infolist is updated)
5 replies
FFilament
Created by ChesterS on 1/23/2024 in #❓┊help
toggleable() not working with Split?
I have the following table columns
Split::make([
TextColumn::make('status')
->badge()
->grow(false)
->toggleable(isToggledHiddenByDefault: true)
->label(__('Status')),
TextColumn::make('created_at')
->toggleable(isToggledHiddenByDefault: true)
->sortable()
->toggledHiddenByDefault(true) // I know it's useless, just here for the example
])->from('md'),
Split::make([
TextColumn::make('status')
->badge()
->grow(false)
->toggleable(isToggledHiddenByDefault: true)
->label(__('Status')),
TextColumn::make('created_at')
->toggleable(isToggledHiddenByDefault: true)
->sortable()
->toggledHiddenByDefault(true) // I know it's useless, just here for the example
])->from('md'),
However, the column is always visible. When I click on the on the checkbox to toggle its visibility, the only thing that changes is that the option disappears from the sorting dropdown. If I remove the Split::make() part and only have the columns, it works as expected Is toggleable() not compatible with Split or am I doing something wrong?
8 replies
FFilament
Created by ChesterS on 1/9/2024 in #❓┊help
Apply filters button + Filters as a slide-over
2 questions really 1) I remember there was a PR that added an Apply button to filters so the table was only filtered when you clicked the button and not when the filters where changed. Do I remember correctly? 2) How do I show the table filters in a slide-over? I set the layout: FiltersLayout::Modal but how do I change it to a slide over?
7 replies
FFilament
Created by ChesterS on 1/3/2024 in #❓┊help
Custom `target` attribute in link Action
Not sure if this is an IBKAC but I can't set a custom target on a link Action. Here is the code
Action::make('link')
->extraAttributes([
'target' => 'does_not_work',
'random_shit' => 'this_works',
])
->link()
Action::make('link')
->extraAttributes([
'target' => 'does_not_work',
'random_shit' => 'this_works',
])
->link()
For some reason, the target attribute does not appear but anything else seems to work. Am I missing something? Is the target attribute filtered for some reason? (I don't want to use openUrlInNewTab() since I don't want to open it in a new tab)
4 replies