I am currently using the default notifications table so am pretty sure it has that covered. When I call $user->unreadNotifications->markAsRead(); it still marks all unread notifications as read, i want to mark a single one
@foreach(Auth::user()->unreadNotifications as $notification)
<li>
<input type="hidden" id="notificationid" value="{{ $notification->id }}" />
{{ $notification->whocommented }} has commented on your post.
</li>
@endforeach
Note: here you may need to adjust id and whocommented.
//call ajax for submitting this form
Now in your controller method-
public function delete(){
//imagine that you have passed id from ajax form submission
$id = request()->input('id')
//assuming that, in notification table there is a column called hasread that is by default 0.
if($hasNotification = Notification::find($id)){
$hasNotification->hasread = 1;
$hasNotification->save();
}
return back();
}