FilamentF
Filament12mo ago
Long✨

How to display notification message?

Hello everyone.
I am building simcard management dashboard.
I have datagrid table prebuilt using filament table, and it contains "Activate simcard" button on each row, so if I click it, modal opens. the modal is built with form.

But what my problem is, after clicking Submit button on modal and after closing a modal, I want to show notification message, of course, I know notification works with livewire component, and @livewire('notifications') part should be added somewhere, but as you know, Filament doesn't provide any livewire component as default, so there is no app.blade.php file as default.

Regarding this problem, I created a new app.blade.php file manually in to resource/views/components/layouts folder, and I added 'layout' => 'components.layouts.app' to config/filament.php, but notification not showing after submitting on modal.

I don't want to create new livewire components for adding form on modal.

// This is SimcardResource class
...
public static function table(Table $table): Table
{
  ...
  ->actions([
                Action::make('simcardActivate')
                    ->label('Aktiver simkort')
                    ->visible(fn (Simcard $record): bool => empty($record->Phone))
                    ->form([
                        ...
                    ])
                    ->action(function (array $data, Simcard $record): void {
                        $baserowApi = new BaserowApi();
                        $response = $baserowApi->updateRecord();

                        if ($response->successful()) {
                            Notification::make()
                                ->title('Success!')
                                ->body('Your action 1 was successful.')
                                ->success()
                                ->send();
                        }
                    })
            ])
}

I am not sure how to display notification without creating livewire component on modal.
Solution
Ok, I found the solution using Render hooks.
Was this page helpful?