Skip to content

Notification

hexters1 edited this page Apr 3, 2022 · 1 revision

Here you can send notifications at once to all admin users listed in config/ladmin.php.

return [

    . . .

    'user' => \App\Models\User::class,

    . . .
];

Notification PopUp

And here you can send notifications to only one user. see example below.

Broadcast Message

Sending broadcasting messages to all registered admins

    ladmin()
    ->notification()
        ->setTitle('New Invoice')
        ->setLink('http://project.test/invoice/31eb6d58-3622-42a4-9206-d36e7a8d6c06')
        ->setDescription('Pay invoice #123455')
        ->setImageLink('http://porject.test/icon-invoice.ong')
        ->setGates(['ladmin.blog.reviewer', 'ladmin.blog.writer'])
    ->send()

Send to Spesific User

Sending messages to only one user, remember that this message can only be sent to users who are initialized to the Illuminate\Foundation\Auth\User class.

    ladmin()
    ->notification( User::first() )
        ->setTitle('New Invoice')
        ->setLink('http://project.test/invoice/31eb6d58-3622-42a4-9206-d36e7a8d6c06')
        ->setDescription('Pay invoice #123455')
        ->setImageLink('http://porject.test/icon-invoice.ong')
        ->setGates(['ladmin.blog.reviewer', 'ladmin.blog.writer'])
    ->send()

Notification Requirement

Option Type required Note
notification ? \Illuminate\Foundation\Auth\User YES Value is not required
setTitle String YES -
setLink String YES -
setImageLink String NO -
setDescription String YES -
setGates Array NO Default all gates

Notification Page

http://localhost:8000/administrator/notification

Notification Page

Listening Notifications

Notifications will broadcast on a private channel formatted using a {notifiable}.{id} convention. View complete Documentation

Echo.private('ladmin.notification.' + userId)
.notification((notification) => {
    console.log(notification.type);
});