feat: festival helper scopes and DevSeeder with full festival structure (TECH-02, TECH-03)

Fix scopeWithChildren to accept an event ID and add scopeForFestival
scope for resolving any event to its full festival context. Extend
DevSeeder with sections, time slots, and persons on the festival.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-10 16:35:01 +02:00
parent d704242279
commit 303280286f
4 changed files with 389 additions and 35 deletions

View File

@@ -221,17 +221,21 @@ final class Event extends Model
return $query->whereIn('event_type', ['festival', 'series']);
}
public function scopeWithChildren(Builder $query): Builder
public function scopeWithChildren(Builder $query, string $eventId): Builder
{
return $query->where(function (Builder $q) {
$q->whereIn('id', function ($sub) {
$sub->select('id')->from('events')->whereNull('parent_event_id');
})->orWhereIn('parent_event_id', function ($sub) {
$sub->select('id')->from('events')->whereNull('parent_event_id');
});
return $query->where(function (Builder $q) use ($eventId) {
$q->where('id', $eventId)
->orWhere('parent_event_id', $eventId);
});
}
public function scopeForFestival(Builder $query, Event $event): Builder
{
$rootId = $event->parent_event_id ?? $event->id;
return $query->withChildren($rootId);
}
// ----- Helpers -----
public function isFestival(): bool