[]]], tags: ['Notifications'], parameters: [ new OA\Parameter(name: 'per_page', description: 'Items per page', in: 'query', schema: new OA\Schema(type: 'integer', example: 15)), ], responses: [ new OA\Response( response: 200, description: 'Notifications fetched successfully', content: new OA\JsonContent( properties: [ new OA\Property(property: 'message', type: 'string', example: 'نوتیفیکیشن‌ها با موفقیت دریافت شد.'), new OA\Property( property: 'data', properties: [ new OA\Property( property: 'notifications', type: 'array', items: new OA\Items(ref: '#/components/schemas/Notification') ), ], type: 'object' ), ] ) ), new OA\Response(response: 401, description: 'Unauthenticated'), ] )] public function index(Request $request): JsonResponse { $perPage = min(max((int) $request->integer('per_page', 15), 1), 100); $notifications = $request->user()->notifications()->paginate($perPage); return $this->success('نوتیفیکیشن‌ها با موفقیت دریافت شد.', [ 'notifications' => NotificationResource::collection($notifications)->response()->getData(true), ]); } #[OA\Post( path: '/notifications/read-all', description: 'Mark all the authenticated user notifications as read', summary: 'Mark all notifications as read', security: [['sanctum' => []]], tags: ['Notifications'], responses: [ new OA\Response( response: 200, description: 'Notifications marked as read successfully', content: new OA\JsonContent( properties: [ new OA\Property(property: 'message', type: 'string', example: 'همه نوتیفیکیشن‌ها خوانده شد.'), new OA\Property(property: 'data', type: 'object'), ] ) ), new OA\Response(response: 401, description: 'Unauthenticated'), ] )] public function markAllAsRead(Request $request): JsonResponse { $this->notificationService->markAllAsRead($request->user()); return $this->success('همه نوتیفیکیشن‌ها خوانده شد.'); } }