Database Notification Mark As Read
Hi fellas, i have this database notification Mark as read is working, but how do i hide that button after that notification is read?
<?php
namespace App\Notifications;
use App\Models\User;
use Filament\Notifications\Actions\Action;
use Filament\Notifications\Notification as FilamentNotification;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
class DatabaseNotification extends Notification
{
use Queueable;
public function __construct(
protected string $view,
protected string $title,
protected array $data = [],
) {}
public function via(object $notifiable): array
{
return ['database'];
}
public function toDatabase(User $notifiable): array
{
return FilamentNotification::make()
->title($this->title)
->body(view($this->view, ['data' => $this->data]))
->actions([
Action::make('Mark as read')
->button()
->markAsRead()
,
])
->getDatabaseMessage();
}
}
0 Replies