Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mstnorris's avatar

Ahh I see, you won't!

$listOfNotificationIdsUserHasSeen = $user->notifications->lists('id');
$newNotifications = DB::table('notifications')
                    ->whereNotIn('id', $listOfNotificationIdsUserHasSeen)->get();
1 like
mstnorris's avatar

You're very welcome. Glad we got there in the end :)

1 like
theUnforgiven's avatar

Yes me too and learnt a lot, give you a mention on Twitter too as a Thank You :-)

mstnorris's avatar

I saw that, thank you. Add gmail to my user name and you can give me a shout should you need anything.

1 like
jbowman99's avatar

I was looking at making a notifications panel basically exactly like whats going on in this thread.

@lstables @mstnorris

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's avatar

@lstables

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

theUnforgiven's avatar

Looks fine to me, if it;s working that way then cool your good to go right?

jbowman99's avatar

@lstables

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

1 like
jbowman99's avatar

@lstables

Ajax call

function markRead(id)
{
    $.ajax({
        type: "GET",
        url: "/notificationRead/" + id,
        success: function (data) {
            console.log('deleted');
        }
    });
}

Previous

Please or to participate in this conversation.