festivalSections()->ordered()->get(); return FestivalSectionResource::collection($sections); } public function store(StoreFestivalSectionRequest $request, Event $event): JsonResponse { Gate::authorize('create', [FestivalSection::class, $event]); $section = $event->festivalSections()->create($request->validated()); return $this->created(new FestivalSectionResource($section)); } public function update(UpdateFestivalSectionRequest $request, Event $event, FestivalSection $section): JsonResponse { Gate::authorize('update', [$section, $event]); $section->update($request->validated()); return $this->success(new FestivalSectionResource($section->fresh())); } public function destroy(Event $event, FestivalSection $section): JsonResponse { Gate::authorize('delete', [$section, $event]); $section->delete(); return response()->json(null, 204); } public function reorder(ReorderFestivalSectionsRequest $request, Event $event): JsonResponse { Gate::authorize('reorder', [FestivalSection::class, $event]); foreach ($request->validated('sections') as $item) { $event->festivalSections() ->where('id', $item['id']) ->update(['sort_order' => $item['sort_order']]); } $sections = $event->festivalSections()->ordered()->get(); return $this->success(FestivalSectionResource::collection($sections)); } }