final class DatabaseChannel implements Channel

Database-backed notification channel.

Persists a notification record to the notifications table using the {\Core\Models\Notifications} model. The payload is expected to be the result of the notification's {\Core\Lib\Notifications\Notification::toDatabase()} and is JSON-encoded for storage.

Example usage (via Notifiable trait): $user->notify(new \App\Notifications\UserRegistered($user));

Methods

static string
name()

Short channel name used in Notification::via().

void
send(object $notifiable, Notification $notification, mixed $payload)

Persist the notification for the given notifiable entity.

Details

at line 35
static string name()

Short channel name used in Notification::via().

Return Value

string

The name of the channel.

at line 62
void send(object $notifiable, Notification $notification, mixed $payload)

Persist the notification for the given notifiable entity.

Accepts mixed per the Channel interface, but expects:

  • $notifiable: an object (typically using the Notifiable trait) exposing a public id (int|string).
  • $notification: an instance of \Core\Lib\Notifications\Notification.
  • $payload: array data produced by toDatabase(), or null.

Parameters

object $notifiable

The user/entity receiving the notification.

Notification $notification

The notification instance.

mixed $payload

Usually the result of toX() (array/DTO)

Return Value

void

Exceptions

ChannelSendFailedException