middleware('auth:web'); } /** * Show the application dashboard. * * @return \Illuminate\Http\Response */ public function index(Request $request) { $setting = Setting::first(); $limit_val = 10; if(isset($setting->data_limit_per_page) && $setting->data_limit_per_page > 0) { $limit_val = $setting->data_limit_per_page; } $notifications = Notification::where('notifiable_id', Auth::user()->id)->orderBy('created_at', 'desc')->paginate($limit_val); return view('notifications', compact('notifications')); } public function headerNotifications(Request $request) { $notifications = Notification::where('notifiable_id', Auth::user()->id)->whereNull('read_at')->orderBy('created_at', 'desc')->get(); $count_not = count($notifications); $request->session()->put('unread_notification_number', $count_not); return view('includes.header-notifications', compact('notifications', 'count_not')); } public function markAsRead() { Notification::where('notifiable_id', Auth::user()->id)->whereNull('read_at')->update(['read_at' => now()->format('Y-m-d H:i:s')]); return back(); } }