F
Filamentβ€’8mo ago
Rolland

Notification Not Showing!

I am implementing custom notification on a custom action button. Here is the code
Forms\Components\Section::make('Import From Box')
->headerActions([
Forms\Components\Actions\Action::make('Fetch')
->action(fn (BoxApi $boxApi, Forms\Set $set, ?array $state) => static::fetchBoxApi($boxApi, $set, $state))
->failureNotification(static::createNotification(
'Value Not Found!', 'Please make sure its a valid URL!'
))
->successNotification(static::createNotification(
'Successful', 'Value Has been Imported!'
)),
])
->schema([
...
])->columns(2),
Forms\Components\Section::make('Import From Box')
->headerActions([
Forms\Components\Actions\Action::make('Fetch')
->action(fn (BoxApi $boxApi, Forms\Set $set, ?array $state) => static::fetchBoxApi($boxApi, $set, $state))
->failureNotification(static::createNotification(
'Value Not Found!', 'Please make sure its a valid URL!'
))
->successNotification(static::createNotification(
'Successful', 'Value Has been Imported!'
)),
])
->schema([
...
])->columns(2),
private static function createNotification(string $title, string $body): Notification
{
return Notification::make()
->danger()
->title($title)
->body($body);
}
private static function createNotification(string $title, string $body): Notification
{
return Notification::make()
->danger()
->title($title)
->body($body);
}
I have set for failure and success notification like this
->failureNotification(static::createNotification(
'Value Not Found!', 'Please make sure its a valid URL!'
))
->successNotification(static::createNotification(
'Successful', 'Value Has been Imported!'
)),
->failureNotification(static::createNotification(
'Value Not Found!', 'Please make sure its a valid URL!'
))
->successNotification(static::createNotification(
'Successful', 'Value Has been Imported!'
)),
and still there's no notification poping up.
Solution:
```php private static function createNotification(string $title, string $body): Notification { return Notification::make() ->danger()...
Jump to solution
3 Replies
toeknee
toekneeβ€’8mo ago
You are not sending it anywhere, so it won't show πŸ˜‰
Solution
toeknee
toekneeβ€’8mo ago
private static function createNotification(string $title, string $body): Notification
{
return Notification::make()
->danger()
->title($title)
->body($body)
->send();
}
private static function createNotification(string $title, string $body): Notification
{
return Notification::make()
->danger()
->title($title)
->body($body)
->send();
}
Rolland
RollandOPβ€’8mo ago
Thank you!
Want results from more Discord servers?
Add your server