Answer the question
In order to leave comments, you need to log in
How to get unread notifications?
Good afternoon.
I use a bunch of Redis + socket.io + laravel-echo server
If the user is online - everything is ok. notifications are coming. But the task is worth it - to display unread notifications if the user was offline. Messages are placed as read when closing via
ajax Redis - only publishes a message to the channel and it doesn't care if someone is there or not.
To do this, I made a Notification model
public static function publish($userId, $data) {
self::create([
'userId' => $userId,
'data' => $data
]);
Redis::publish('private-user.'.$userId, json_encode($data));
}
Notification::publish($user->id, $data);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question