id()) ->orderBy('created_at', 'desc') ->paginate(20); return response()->json($notifications); } public function markRead(Notification $notification): JsonResponse { if ($notification->user_id !== auth()->id()) { return response()->json(['message' => 'دسترسی غیرمجاز'], 403); } $notification->update(['is_read' => true]); return response()->json($notification); } public function markAllRead(): JsonResponse { Notification::where('user_id', auth()->id()) ->where('is_read', false) ->update(['is_read' => true]); return response()->json(['message' => 'همه اعلان‌ها خوانده شد']); } public function unreadCount(): JsonResponse { $count = Notification::where('user_id', auth()->id()) ->where('is_read', false) ->count(); return response()->json(['count' => $count]); } }