orderby('updated_at','desc'); } public function show(Notification $notification) { return $notification; } public function store(Request $request) { $notification = Notification::create($request->all()); return response()->json($notification, 201); } public function update(Request $request, Notification $notification) { $notification->update($request->all()); return response()->json($notification, 200); } public function delete(Notification $notification) { $notification->delete(); return response()->json(null, 204); } public function getUserMessage() { return response()->json([ "message" =>Notification::Where("user_id",Auth::user()->id)->orderby('updated_at','desc')->get(), "unread_message" =>Notification::Where([ ["user_id",Auth::user()->id], ["is_read",0] ])->orderby('updated_at','desc')->get() ],200); } public function readNotification(){ $affected = DB::table('notifications')->Where('user_id', Auth::user()->id)->update(array('is_read' => 1)); return response()->json("Read all message", 200); } }