This is the default laravel notifications
data
field
{
"type":"Update Appointment",
"appointment_id":"379",
"date":null,
"updated_by":"Mahir",
"status":"2"
}
In controller
i want to get all notifications with status = 2
and mark as read
Laravel 5.3 doc shows
$user = App\User::find(1);
foreach ($user->unreadNotifications as $notification) {
$notification->markAsRead();
}
How do i modify this to get all notifications with status = 2
Update : looking for something like this
$noti = $user->unreadNotifications->where('data->status',"2");
Note : my database doesn't support json
data type.
According to laravel 5.6: JSON Where Clauses
and work with MySQL 5.7
I hope this answer help you
I think, you can create your own channel, (see also Illuminate\Notifications\Channels\DatabaseChannel), where you can override send() method, for saving your notifications. Before that, you can write your migration to update "notifications" table to add your custom filtering field. See: https://laravel.com/docs/5.5/notifications#custom-channels
Sorry for my English. Hope, you'll understand.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With