[Vuejs]-How to persist data for newly logged in users?

0👍

In order to save notifications for users, you need to use database method,
see here : https://laravel.com/docs/8.x/notifications
So, first you need to migrate the table :

php artisan notifications:table
php artisan migrate

Then, in your notification file, set this :

public function toDatabase($notifiable)
{
    return [
        'foo_id' => $this->foo->id,
        'value' => $this->foo->value,
    ];
}

Finally, you may get unread notifications for a given user like this :

foreach ($user->unreadNotifications as $notification) {
    echo $notification->type;
}

Leave a comment