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(),

View File

@@ -17,9 +17,8 @@ final class ReorderFestivalSectionsRequest extends FormRequest
public function rules(): array
{
return [
'sections' => ['required', 'array'],
'sections.*.id' => ['required', 'ulid'],
'sections.*.sort_order' => ['required', 'integer', 'min:0'],
'sections' => ['required', 'array', 'min:1'],
'sections.*' => ['required', 'ulid'],
];
}
}

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Http\Requests\Api\V1;
use App\Models\Event;
use Illuminate\Foundation\Http\FormRequest;
final class StoreFestivalSectionRequest extends FormRequest
@@ -18,10 +19,26 @@ final class StoreFestivalSectionRequest extends FormRequest
{
return [
'name' => ['required', 'string', 'max:255'],
'category' => ['nullable', 'string', 'max:50'],
'icon' => ['nullable', 'string', 'max:50'],
'sort_order' => ['nullable', 'integer', 'min:0'],
'type' => ['nullable', 'in:standard,cross_event'],
'crew_need' => ['nullable', 'integer', 'min:0'],
'crew_auto_accepts' => ['nullable', 'boolean'],
'crew_invited_to_events' => ['nullable', 'boolean'],
'added_to_timeline' => ['nullable', 'boolean'],
'responder_self_checkin' => ['nullable', 'boolean'],
'crew_accreditation_level' => ['nullable', 'string', 'max:50'],
'public_form_accreditation_level' => ['nullable', 'string', 'max:50'],
'timed_accreditations' => ['nullable', 'boolean'],
];
}
/** @return array<string, string> */
public function messages(): array
{
return [
'type.in' => 'Type moet standard of cross_event zijn.',
];
}
}

View File

@@ -17,12 +17,12 @@ final class UpdateEventRequest extends FormRequest
public function rules(): array
{
return [
// Status changes must go through POST /events/{event}/transition
'name' => ['sometimes', 'string', 'max:255'],
'slug' => ['sometimes', 'string', 'max:255', 'regex:/^[a-z0-9-]+$/'],
'start_date' => ['sometimes', 'date'],
'end_date' => ['sometimes', 'date', 'after_or_equal:start_date'],
'timezone' => ['sometimes', 'string', 'max:50'],
'status' => ['sometimes', 'string', 'in:draft,published,registration_open,buildup,showday,teardown,closed'],
'parent_event_id' => ['nullable', 'ulid', 'exists:events,id'],
'event_type' => ['sometimes', 'in:event,festival,series'],
'event_type_label' => ['nullable', 'string', 'max:50'],

View File

@@ -18,6 +18,8 @@ final class UpdateFestivalSectionRequest extends FormRequest
{
return [
'name' => ['sometimes', 'string', 'max:255'],
'category' => ['sometimes', 'nullable', 'string', 'max:50'],
'icon' => ['sometimes', 'nullable', 'string', 'max:50'],
'sort_order' => ['sometimes', 'integer', 'min:0'],
'type' => ['sometimes', 'in:standard,cross_event'],
'crew_auto_accepts' => ['sometimes', 'boolean'],

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Http\Resources\Api\V1;
use App\Models\Event;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
@@ -21,6 +22,7 @@ final class EventResource extends JsonResource
'end_date' => $this->end_date->toDateString(),
'timezone' => $this->timezone,
'status' => $this->status,
'allowed_transitions' => Event::STATUS_TRANSITIONS[$this->status] ?? [],
'event_type' => $this->event_type,
'event_type_label' => $this->event_type_label,
'sub_event_label' => $this->sub_event_label,

View File

@@ -15,13 +15,18 @@ final class FestivalSectionResource extends JsonResource
'id' => $this->id,
'event_id' => $this->event_id,
'name' => $this->name,
'category' => $this->category,
'icon' => $this->icon,
'type' => $this->type,
'sort_order' => $this->sort_order,
'crew_need' => $this->crew_need,
'crew_auto_accepts' => $this->crew_auto_accepts,
'responder_self_checkin' => $this->responder_self_checkin,
'crew_invited_to_events' => $this->crew_invited_to_events,
'added_to_timeline' => $this->added_to_timeline,
'responder_self_checkin' => $this->responder_self_checkin,
'crew_accreditation_level' => $this->crew_accreditation_level,
'public_form_accreditation_level' => $this->public_form_accreditation_level,
'timed_accreditations' => $this->timed_accreditations,
'created_at' => $this->created_at->toIso8601String(),
'shifts_count' => $this->whenCounted('shifts'),
];

View File

@@ -6,6 +6,7 @@ namespace App\Http\Resources\Api\V1;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Carbon;
final class ShiftResource extends JsonResource
{
@@ -26,15 +27,18 @@ final class ShiftResource extends JsonResource
'slots_total' => $this->slots_total,
'slots_open_for_claiming' => $this->slots_open_for_claiming,
'is_lead_role' => $this->is_lead_role,
'report_time' => $this->report_time,
'actual_start_time' => $this->actual_start_time,
'actual_end_time' => $this->actual_end_time,
'report_time' => $this->report_time ? Carbon::parse($this->report_time)->format('H:i') : null,
'actual_start_time' => $this->actual_start_time ? Carbon::parse($this->actual_start_time)->format('H:i') : null,
'actual_end_time' => $this->actual_end_time ? Carbon::parse($this->actual_end_time)->format('H:i') : null,
'end_date' => $this->end_date?->toDateString(),
'allow_overlap' => $this->allow_overlap,
'events_during_shift' => $this->events_during_shift,
'assigned_crew_id' => $this->assigned_crew_id,
'status' => $this->status,
'filled_slots' => $this->filled_slots,
'fill_rate' => $this->fill_rate,
'effective_start_time' => $this->effective_start_time,
'effective_end_time' => $this->effective_end_time,
'effective_start_time' => $this->effective_start_time ? Carbon::parse($this->effective_start_time)->format('H:i') : null,
'effective_end_time' => $this->effective_end_time ? Carbon::parse($this->effective_end_time)->format('H:i') : null,
'created_at' => $this->created_at->toIso8601String(),
'time_slot' => new TimeSlotResource($this->whenLoaded('timeSlot')),
'location' => new LocationResource($this->whenLoaded('location')),