Mark as read once notification is opened

How can I mark a database notification as read once it is opened with the action I have configured?

protected function afterCreate(): void
{
    $ticket = $this->record;
    $recipient = User::query()->role('admin')->get();

    Notification::make()
        ->title('New Ticket')
        ->icon('heroicon-o-ticket')
        ->body("**{$ticket->customer->name} has created a new ticket.**")
        ->actions([
            Action::make('View')
                ->url(TicketResource::getUrl('edit', ['record' => $ticket])),
        ])
        ->sendToDatabase($recipient);
}

And if the same notification is sent to different usersand if a user makes a change in a specific record field, is it possible to mark the rest of the notifications sent to the rest of the users as read?
Was this page helpful?