feat: festival/series model with sub-events, cross-event sections, tab navigation, SectionsShiftsPanel extraction
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,17 @@ final class FestivalSectionController extends Controller
|
||||
|
||||
$sections = $event->festivalSections()->ordered()->get();
|
||||
|
||||
// For sub-events, also include cross_event sections from the parent festival
|
||||
if ($event->isSubEvent()) {
|
||||
$parentCrossEventSections = $event->parent
|
||||
->festivalSections()
|
||||
->where('type', 'cross_event')
|
||||
->ordered()
|
||||
->get();
|
||||
|
||||
$sections = $parentCrossEventSections->merge($sections)->sortBy('sort_order')->values();
|
||||
}
|
||||
|
||||
return FestivalSectionResource::collection($sections);
|
||||
}
|
||||
|
||||
@@ -30,9 +41,39 @@ final class FestivalSectionController extends Controller
|
||||
{
|
||||
Gate::authorize('create', [FestivalSection::class, $event]);
|
||||
|
||||
$section = $event->festivalSections()->create($request->validated());
|
||||
$data = $request->validated();
|
||||
$redirectedToParent = false;
|
||||
|
||||
return $this->created(new FestivalSectionResource($section));
|
||||
if (($data['type'] ?? 'standard') === 'cross_event') {
|
||||
if ($event->isFlatEvent()) {
|
||||
return $this->error(
|
||||
'Overkoepelende secties kunnen alleen worden aangemaakt bij festivals met programmaonderdelen.',
|
||||
422,
|
||||
);
|
||||
}
|
||||
|
||||
if ($event->isSubEvent()) {
|
||||
$event = $event->parent;
|
||||
Gate::authorize('create', [FestivalSection::class, $event]);
|
||||
$redirectedToParent = true;
|
||||
}
|
||||
}
|
||||
|
||||
$section = $event->festivalSections()->create($data);
|
||||
|
||||
$response = $this->created(new FestivalSectionResource($section));
|
||||
|
||||
if ($redirectedToParent) {
|
||||
$original = $response->getData(true);
|
||||
$original['meta'] = [
|
||||
'redirected_to_parent' => true,
|
||||
'parent_event_name' => $event->name,
|
||||
];
|
||||
|
||||
return response()->json($original, 201);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function update(UpdateFestivalSectionRequest $request, Event $event, FestivalSection $section): JsonResponse
|
||||
@@ -57,10 +98,10 @@ final class FestivalSectionController extends Controller
|
||||
{
|
||||
Gate::authorize('reorder', [FestivalSection::class, $event]);
|
||||
|
||||
foreach ($request->validated('sections') as $item) {
|
||||
foreach ($request->validated('sections') as $index => $id) {
|
||||
$event->festivalSections()
|
||||
->where('id', $item['id'])
|
||||
->update(['sort_order' => $item['sort_order']]);
|
||||
->where('id', $id)
|
||||
->update(['sort_order' => $index]);
|
||||
}
|
||||
|
||||
$sections = $event->festivalSections()->ordered()->get();
|
||||
|
||||
Reference in New Issue
Block a user