has('id')) { $notification = $request->user()->notifications()->where('id', $request->id)->first(); if ($notification) { $notification->markAsRead(); } return response()->json(['success' => true]); } else { $request->user()->unreadNotifications->markAsRead(); return response()->json(['success' => true]); } } } }