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:
2026-04-10 11:15:19 +02:00
parent 11b9f1d399
commit 10bd55b8ae
40 changed files with 3087 additions and 1080 deletions

View File

@@ -63,7 +63,7 @@ final class EventController extends Controller
}
if (!isset($data['event_type'])) {
$data['event_type'] = empty($data['parent_event_id']) ? 'event' : 'event';
$data['event_type'] = 'event';
}
$event = $organisation->events()->create($data);
@@ -80,6 +80,39 @@ final class EventController extends Controller
return $this->success(new EventResource($event->fresh()));
}
public function destroy(Organisation $organisation, Event $event): JsonResponse
{
Gate::authorize('delete', [$event, $organisation]);
$event->delete();
return $this->success(null, 'Event deleted');
}
public function transition(Request $request, Organisation $organisation, Event $event): JsonResponse
{
Gate::authorize('update', [$event, $organisation]);
$request->validate(['status' => 'required|string']);
$newStatus = $request->status;
$result = $event->canTransitionToWithPrerequisites($newStatus);
if (! empty($result['errors'])) {
return response()->json([
'message' => 'Status transition not possible.',
'errors' => $result['errors'],
'current_status' => $event->status,
'requested_status' => $newStatus,
'allowed_transitions' => Event::STATUS_TRANSITIONS[$event->status] ?? [],
], 422);
}
$event->transitionTo($newStatus);
return $this->success(new EventResource($event->fresh()));
}
public function children(Organisation $organisation, Event $event): AnonymousResourceCollection
{
Gate::authorize('view', [$event, $organisation]);

View File

@@ -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();

View File

@@ -26,6 +26,7 @@ final class ShiftController extends Controller
$shifts = $section->shifts()
->with(['timeSlot', 'location'])
->withCount(['shiftAssignments as filled_slots' => fn ($q) => $q->where('status', 'approved')])
->get();
return ShiftResource::collection($shifts);
@@ -84,13 +85,11 @@ final class ShiftController extends Controller
}
}
$autoApprove = $section->crew_auto_accepts;
$assignment = $shift->shiftAssignments()->create([
'person_id' => $personId,
'time_slot_id' => $shift->time_slot_id,
'status' => $autoApprove ? 'approved' : 'approved',
'auto_approved' => $autoApprove,
'status' => 'approved',
'auto_approved' => false,
'assigned_by' => $request->user()->id,
'assigned_at' => now(),
'approved_at' => now(),