dev-resources.site
for different kinds of informations.
Filamentphp 3 : Custom Database Notification Actions
Published at
10/7/2023
Categories
laravel
filamentphp
php
notifications
Author
Rupadana
Introduction
In filamentphp there are called Database notification, which is we can notify specify user. Read documentation
What's The problem?
There are a Mark all as read
action. How we can override the method of that action?
Solution
First, we need to create a livewire component, let's call it DatabaseCustomNotifications
php artisan make:livewire DatabaseCustomNotifications
That will be create file in app\Livewire\DatabaseCustomNotifications
, and looks like this
<?php
namespace App\Livewire;
use Livewire\Component;
class DatabaseCustomNotifications extends Component
{
}
Next, You need change extends to Filament\Livewire\DatabaseNotifications
.
<?php
namespace App\Livewire;
use Filament\Livewire\DatabaseNotifications;
use Livewire\Attributes\On;
use Livewire\Component;
class DatabaseCustomNotifications extends DatabaseNotifications
{
}
Next, Use the livewire component in your blade.
@livewire('database-custom-notifications')
Next, let's override markAllNotificationsAsRead
method
<?php
namespace App\Livewire;
use Filament\Livewire\DatabaseNotifications;
use Livewire\Attributes\On;
use Livewire\Component;
class DatabaseCustomNotifications extends DatabaseNotifications
{
public function markAllNotificationsAsRead(): void
{
dd("Got it");
$this->getUnreadNotificationsQuery()->update(['read_at' => now()]);
}
}
And finally, you can modify that action.
Articles
12 articles in total
Filament Tips : Modal View on the Table Action
read article
Filamentphp 3 : Custom Database Notification Actions
currently reading
FilamentApiService : Create a custom handler
read article
Filamentphp 3 : Input Group with Filament Field
read article
How to use Filament Api Service Plugin
read article
Renew SSL Letβs Encrypt
read article
Generate Free SSL Certonly
read article
Install and Manage Supervisor for Laravel Queue
read article
Hide filamentphp default Widget
read article
Optimizing Next.js Performance with Code Splitting and Dynamic Imports
read article
Create Stats overview widgets
read article
Creating a new panel
read article
Featured ones: