[]]], parameters: [ new OA\Parameter(name: 'course_id', in: 'query', required: false, schema: new OA\Schema(type: 'integer')), new OA\Parameter(name: 'per_page', in: 'query', required: false, schema: new OA\Schema(type: 'integer', default: 15)), ], responses: [new OA\Response(response: 200, description: 'Takvim listesi')], )] public function index(Request $request): AnonymousResourceCollection { $schedules = $this->repository->paginate( $request->only(['course_id']), $request->integer('per_page', 15), ); return CourseScheduleResource::collection($schedules); } #[OA\Post( path: '/api/admin/schedules', summary: 'Yeni takvim oluştur', tags: ['Admin - Schedules'], security: [['sanctum' => []]], requestBody: new OA\RequestBody(required: true, content: new OA\JsonContent( required: ['course_id', 'start_date', 'location', 'quota'], properties: [ new OA\Property(property: 'course_id', type: 'integer'), new OA\Property(property: 'start_date', type: 'string', format: 'date'), new OA\Property(property: 'end_date', type: 'string', format: 'date'), new OA\Property(property: 'location', type: 'string'), new OA\Property(property: 'instructor', type: 'string'), new OA\Property(property: 'quota', type: 'integer'), new OA\Property(property: 'enrolled_count', type: 'integer'), new OA\Property(property: 'price_override', type: 'number'), new OA\Property(property: 'status', type: 'string'), new OA\Property(property: 'notes', type: 'string'), ], )), responses: [ new OA\Response(response: 201, description: 'Takvim oluşturuldu'), new OA\Response(response: 422, description: 'Validasyon hatası'), ], )] public function store(StoreScheduleRequest $request, CreateScheduleAction $action): JsonResponse { $dto = ScheduleData::fromArray($request->validated()); $schedule = $action->execute($dto); return response()->json(new CourseScheduleResource($schedule->load('course')), 201); } #[OA\Get( path: '/api/admin/schedules/{schedule}', summary: 'Takvim detayı (Admin)', tags: ['Admin - Schedules'], security: [['sanctum' => []]], parameters: [new OA\Parameter(name: 'schedule', in: 'path', required: true, schema: new OA\Schema(type: 'integer'))], responses: [new OA\Response(response: 200, description: 'Takvim detayı')], )] public function show(CourseSchedule $schedule): JsonResponse { return response()->json(new CourseScheduleResource($schedule->load('course'))); } #[OA\Put( path: '/api/admin/schedules/{schedule}', summary: 'Takvim güncelle', tags: ['Admin - Schedules'], security: [['sanctum' => []]], parameters: [new OA\Parameter(name: 'schedule', in: 'path', required: true, schema: new OA\Schema(type: 'integer'))], requestBody: new OA\RequestBody(required: true, content: new OA\JsonContent( properties: [ new OA\Property(property: 'course_id', type: 'integer'), new OA\Property(property: 'start_date', type: 'string', format: 'date'), new OA\Property(property: 'end_date', type: 'string', format: 'date'), new OA\Property(property: 'location', type: 'string'), new OA\Property(property: 'instructor', type: 'string'), new OA\Property(property: 'quota', type: 'integer'), new OA\Property(property: 'status', type: 'string'), ], )), responses: [ new OA\Response(response: 200, description: 'Takvim güncellendi'), new OA\Response(response: 422, description: 'Validasyon hatası'), ], )] public function update(UpdateScheduleRequest $request, CourseSchedule $schedule, UpdateScheduleAction $action): JsonResponse { $dto = ScheduleData::fromArray(array_merge($schedule->toArray(), $request->validated())); $schedule = $action->execute($schedule, $dto); return response()->json(new CourseScheduleResource($schedule->load('course'))); } #[OA\Delete( path: '/api/admin/schedules/{schedule}', summary: 'Takvim sil', tags: ['Admin - Schedules'], security: [['sanctum' => []]], parameters: [new OA\Parameter(name: 'schedule', in: 'path', required: true, schema: new OA\Schema(type: 'integer'))], responses: [new OA\Response(response: 200, description: 'Takvim silindi')], )] public function destroy(CourseSchedule $schedule, DeleteScheduleAction $action): JsonResponse { $action->execute($schedule); return response()->json(['message' => 'Takvim silindi.']); } }