25 lines
1.5 KiB
Markdown
25 lines
1.5 KiB
Markdown
# Lucent Notifications
|
|
|
|
This package is responsible for creating and pushing notifications. Notifications can be either sent via mail, broadcasted using SSE and they are stored inside the database.
|
|
|
|
## Creating Notifications
|
|
Every notification is an instance of `LucentNotifications\Models\Notification` model. There is a static function caled ::create which facilitates the creation of the notification.
|
|
|
|
### Mail notifications
|
|
The static::create function accepts a Mailable class as its mail parameter. Lucent Notifications will instanciate the new Mailable class with the following parameters:
|
|
# Notification $notification,
|
|
# array $userFrom and
|
|
# array $userTo
|
|
so keep that in mind when defining your own Mailable class
|
|
|
|
|
|
## Dispatching Notifications
|
|
Notifications are Dispatched using the `LucentNotifications\Events\NotificationsDispatcher` event in order to be dispatched. The dispatcher accepts an array of Notification objects and dispatches them to the default queue.
|
|
|
|
|
|
## Listening for broadcasted notifications
|
|
Notifications are broadcasteded on the `broadcast/notifications` route. Yoy can easily listen for messages using an EventSource in js.
|
|
|
|
## Retrieving notifications
|
|
Notifications can be retrieved using the HookManager's get-notifications function. The function accepts an array of filters.
|
|
When the string 'unread' is passed, it will fetch al unread notifications. Otherwise you can filter based on key => values for the following fields: userIdFrom, type |