feat: festival/event model frontend + topbar activeren

- Events lijst: card grid met festival/serie chips
- Festival detail: programmaonderdelen grid
- CreateSubEventDialog voor sub-events binnen festival
- EventTabsNav: breadcrumb terug naar festival
- Sessie A: festival-bewuste EventResource + children endpoint
- Topbar: zoekbalk, theme switcher, shortcuts, notificaties
- Schema v1.7 + BACKLOG.md toegevoegd
- 121 tests groen
This commit is contained in:
2026-04-08 10:06:47 +02:00
parent 6848bc2c49
commit c776331cf8
21 changed files with 1087 additions and 190 deletions

View File

@@ -11,34 +11,62 @@ use App\Http\Resources\Api\V1\EventResource;
use App\Models\Event;
use App\Models\Organisation;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
use Illuminate\Support\Facades\Gate;
final class EventController extends Controller
{
public function index(Organisation $organisation): AnonymousResourceCollection
public function index(Request $request, Organisation $organisation): AnonymousResourceCollection
{
Gate::authorize('viewAny', [Event::class, $organisation]);
$events = $organisation->events()
->latest('start_date')
->paginate();
$query = $organisation->events()
->topLevel()
->latest('start_date');
return EventResource::collection($events);
if ($request->query('type')) {
$query->where('event_type', $request->query('type'));
}
if ($request->boolean('include_children')) {
$query->with('children');
}
return EventResource::collection($query->paginate());
}
public function show(Organisation $organisation, Event $event): JsonResponse
{
Gate::authorize('view', [$event, $organisation]);
return $this->success(new EventResource($event->load('organisation')));
$event->load(['organisation', 'children', 'parent'])
->loadCount('children');
return $this->success(new EventResource($event));
}
public function store(StoreEventRequest $request, Organisation $organisation): JsonResponse
{
Gate::authorize('create', [Event::class, $organisation]);
$event = $organisation->events()->create($request->validated());
$data = $request->validated();
if (!empty($data['parent_event_id'])) {
$parentEvent = Event::where('id', $data['parent_event_id'])
->where('organisation_id', $organisation->id)
->first();
if (!$parentEvent) {
return $this->error('Parent event does not belong to this organisation.', 422);
}
}
if (!isset($data['event_type'])) {
$data['event_type'] = empty($data['parent_event_id']) ? 'event' : 'event';
}
$event = $organisation->events()->create($data);
return $this->created(new EventResource($event));
}
@@ -51,4 +79,16 @@ final class EventController extends Controller
return $this->success(new EventResource($event->fresh()));
}
public function children(Organisation $organisation, Event $event): AnonymousResourceCollection
{
Gate::authorize('view', [$event, $organisation]);
$children = $event->children()
->orderBy('start_date')
->orderBy('name')
->paginate();
return EventResource::collection($children);
}
}

View File

@@ -23,6 +23,10 @@ final class StoreEventRequest extends FormRequest
'end_date' => ['required', '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' => ['nullable', 'in:event,festival,series'],
'event_type_label' => ['nullable', 'string', 'max:50'],
'sub_event_label' => ['nullable', 'string', 'max:50'],
];
}
}

View File

@@ -23,6 +23,10 @@ final class UpdateEventRequest extends FormRequest
'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'],
'sub_event_label' => ['nullable', 'string', 'max:50'],
];
}
}

View File

@@ -14,15 +14,27 @@ final class EventResource extends JsonResource
return [
'id' => $this->id,
'organisation_id' => $this->organisation_id,
'parent_event_id' => $this->parent_event_id,
'name' => $this->name,
'slug' => $this->slug,
'start_date' => $this->start_date->toDateString(),
'end_date' => $this->end_date->toDateString(),
'timezone' => $this->timezone,
'status' => $this->status,
'event_type' => $this->event_type,
'event_type_label' => $this->event_type_label,
'sub_event_label' => $this->sub_event_label,
'is_recurring' => $this->is_recurring,
'is_festival' => $this->resource->isFestival(),
'is_sub_event' => $this->resource->isSubEvent(),
'is_flat_event' => $this->resource->isFlatEvent(),
'has_children' => $this->resource->hasChildren(),
'created_at' => $this->created_at->toIso8601String(),
'updated_at' => $this->updated_at->toIso8601String(),
'children_count' => $this->whenCounted('children'),
'organisation' => new OrganisationResource($this->whenLoaded('organisation')),
'parent' => new EventResource($this->whenLoaded('parent')),
'children' => EventResource::collection($this->whenLoaded('children')),
];
}
}