Skip to content

Notifications

Sending notifications in PHP

Diagram
$notification = new CenterNotification('Title', 'Message');
$notification->data(['key' => 'value']);
$user->notify($notification);

Updating notifications, where $id is the ID of the notification to update:

$notification = new CenterNotification('Updated title', 'Message');
$notification->updates($id); // Specify the notification that should be updated
$notification->data(['key' => 'value']);
$user->notify($notification);

Classes

CenterNotification

The CenterNotification class. This is the class that should be interacted with when creating and sending notifications. It is not an Eloquent model. Rather, CenterNotification is sent to the NotificationCenterChannel and the WebPush channel classes, which transform the object into the data representation they need.

NotificationCenterEntry

The NotificationCenterEntry class is an Eloquent model describing a stored notification with the ID from CenterNotification. It can be constructed by calling toNotificationCenterEntry on a CenterNotification. This model is managed by the NotificationCenter class, which is represented as a singleton with app(NotificationCenter::class).

WebPushMessage

The WebPushMessage class is used by the WebPushChannel and can be constructed by calling toWebPush on a CenterNotification.

WorkflowNotification

The WorkflowNotification class is a basic model that is fed with data from action/notify workflow element. It can be transformed to a ToastMessage, a Mailable and to a CenterNotification.