feat: registration section preferences with show_in_registration filtering and deduplication

Add show_in_registration and registration_description columns to festival_sections.
Registration form now shows deduplicated sections by name (across sub-events),
filtered by show_in_registration=true, grouped by category with card-based UI.
Section preferences use section_name instead of section_id.
Add GET/PUT registration-settings endpoints for festival-level bulk management.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-10 20:03:54 +02:00
parent 3400e4cc7e
commit c21bc085e9
22 changed files with 1443 additions and 104 deletions

View File

@@ -8,6 +8,7 @@ use App\Http\Controllers\Controller;
use App\Http\Requests\Api\V1\ReorderFestivalSectionsRequest;
use App\Http\Requests\Api\V1\StoreFestivalSectionRequest;
use App\Http\Requests\Api\V1\UpdateFestivalSectionRequest;
use App\Http\Requests\Api\V1\UpdateRegistrationSettingsRequest;
use App\Http\Resources\Api\V1\FestivalSectionResource;
use App\Models\Event;
use App\Models\FestivalSection;
@@ -94,6 +95,82 @@ final class FestivalSectionController extends Controller
return response()->json(null, 204);
}
public function registrationSettings(Event $event): JsonResponse
{
Gate::authorize('viewAny', [FestivalSection::class, $event]);
$sections = $this->getFestivalSections($event);
$grouped = $sections->groupBy('name')->map(function ($group) {
$first = $group->first();
return [
'name' => $first->name,
'category' => $first->category,
'icon' => $first->icon,
'show_in_registration' => $group->contains('show_in_registration', true),
'registration_description' => $group->whereNotNull('registration_description')->first()?->registration_description,
'section_count' => $group->count(),
'section_ids' => $group->pluck('id')->values()->toArray(),
];
})->values();
return response()->json(['data' => $grouped]);
}
public function updateRegistrationSettings(UpdateRegistrationSettingsRequest $request, Event $event): JsonResponse
{
Gate::authorize('create', [FestivalSection::class, $event]);
$validated = $request->validated();
$sections = $this->getFestivalSections($event);
$matching = $sections->where('name', $validated['name']);
if ($matching->isEmpty()) {
return $this->error('Sectie niet gevonden.', 404);
}
FestivalSection::whereIn('id', $matching->pluck('id'))
->update([
'show_in_registration' => $validated['show_in_registration'],
'registration_description' => $validated['registration_description'],
]);
activity('section_management')
->performedOn($event)
->causedBy(auth()->user())
->withProperties([
'section_name' => $validated['name'],
'show_in_registration' => $validated['show_in_registration'],
'sections_updated' => $matching->count(),
])
->log('section.registration_settings_updated');
// Return updated settings
return $this->registrationSettings($event);
}
/**
* Get all sections across the festival context (parent + children).
*/
private function getFestivalSections(Event $event): \Illuminate\Support\Collection
{
$eventIds = collect([$event->id]);
if ($event->isSubEvent()) {
$parentId = $event->parent_event_id;
$eventIds = Event::where('parent_event_id', $parentId)
->orWhere('id', $parentId)
->pluck('id');
} elseif ($event->hasChildren()) {
$childIds = $event->children()->pluck('id');
$eventIds = $childIds->push($event->id);
}
return FestivalSection::whereIn('event_id', $eventIds)->ordered()->get();
}
public function reorder(ReorderFestivalSectionsRequest $request, Event $event): JsonResponse
{
Gate::authorize('reorder', [FestivalSection::class, $event]);