Notification Not Showing!
I am implementing custom notification on a custom action button. Here is the code
I have set for failure and success notification like this
and still there's no notification poping up.
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);
}
->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!'
)),
Solution:Jump to solution
```php
private static function createNotification(string $title, string $body): Notification
{
return Notification::make()
->danger()...
3 Replies
You are not sending it anywhere, so it won't show π
Solution
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();
}
Thank you!