Ahh I see, you won't!
$listOfNotificationIdsUserHasSeen = $user->notifications->lists('id');
$newNotifications = DB::table('notifications')
->whereNotIn('id', $listOfNotificationIdsUserHasSeen)->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Ahh I see, you won't!
$listOfNotificationIdsUserHasSeen = $user->notifications->lists('id');
$newNotifications = DB::table('notifications')
->whereNotIn('id', $listOfNotificationIdsUserHasSeen)->get();
Absolute legend @mstnorris sorted. Thanks a billion dude!
You're very welcome. Glad we got there in the end :)
Yes me too and learnt a lot, give you a mention on Twitter too as a Thank You :-)
I saw that, thank you. Add gmail to my user name and you can give me a shout should you need anything.
Cool, thanks.
I was looking at making a notifications panel basically exactly like whats going on in this thread.
my set up is roughly the same as you guys are describing in this thread, and i am having problems updating a
read
variable in my notifiction_user table which is a Boolean defaulting to 0. When a user has read it i have an button that will mark it as read update the pivot and that user will not longer be able to see the notification.
I am currently not able to access the variable on the pivot table to update it in my controller method...I found this thread and was following along but I still can't seem to update the pivot...
Any chance of lending me a hand?
@jbowman99 How are you trying to update the table, can you show your code.
I have gotten the notification table to update like this and its working now,
$notification->users()->attach(Auth::user(), ['read' => 1]);
I'm not sure it that would be the correct way of doing it but it is working from a mysql point of view the table is updated
Jon
Looks fine to me, if it;s working that way then cool your good to go right?
My problem with the notification system now is loading a list of all users into the select box and then figuring out how to connect my ajax call to check the pivot table to see whether the specific user has read or not read the notification
Thanks for the help
Hows your ajax call look?
Ajax call
function markRead(id)
{
$.ajax({
type: "GET",
url: "/notificationRead/" + id,
success: function (data) {
console.log('deleted');
}
});
}
@theUnforgiven can you show me your controller method to store notification ?
Please or to participate in this conversation.