notifications()->orderBy('created_at', 'desc')->limit(5)->get(); } public function goToNotification($id) { $notification = Auth::user()->notifications()->where('id', $id)->first(); if (!$notification) { return; } $notification->markAsRead(); if ($notification->url) { return $this->redirect($notification->url, true); } } public function markAsRead($id) { $notification = Auth::user()->notifications()->where('id', $id)->first(); if (!$notification) { return; } $notification->markAsRead(); } public function render() { return view('components.notifications'); } }