I have a page in my application that displays a list of all of the notifications a user currently has that are unread and each notification will have a read icon.
The ID in the database is set to char
so is a long string of letters and numbers. When I display the id of the notifications on the page, they all return numbers that in no way relate to what is in the database so when I run a query to read a notification, it can't find the ID because the ID isn't matching.
What is the best method to read a single notification in Laravel? I'm using the code below to try, but it's the $request->get('id')
that's incorrect as I seem to get 12310 as an ID and even 0 for some of them.
Auth::user()->unreadNotifications->where('id', $request->get('id'))->markAsRead()