Files
crewli/api/app/Http/Controllers/Api/V1/PublicRegistrationDataController.php
bert.hausmans 0d741550a8 feat: event registration branding with vertical wizard layout
- Add registration_banner_url, registration_welcome_text, registration_logo_url
  columns to events table with migration
- Add uploadImage endpoint (POST .../upload-image) with form request validation
  for banner and logo images (jpg/png/webp, max 5MB)
- Include branding fields in EventResource and PublicRegistrationDataController
- Build registration settings UI in organizer event settings page with
  banner/logo upload and welcome text editor
- Redesign portal registration page: hero banner with gradient overlay,
  welcome text card, vertical step navigation (desktop) / horizontal chips
  (mobile), two-column form fields with density="comfortable"
- Update success page with event banner and consistent branding
- Seed welcome text for Echt Feesten 2026
- Add 9 PHPUnit tests covering image upload, branding fields in API responses

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 21:09:49 +02:00

86 lines
3.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Controllers\Api\V1;
use App\Http\Controllers\Controller;
use App\Models\Event;
use App\Models\FestivalSection;
use App\Models\TimeSlot;
use Illuminate\Http\JsonResponse;
final class PublicRegistrationDataController extends Controller
{
public function __invoke(string $slug): JsonResponse
{
$event = Event::where('slug', $slug)
->where('status', 'registration_open')
->first();
if ($event === null) {
abort(404, 'Event not found or not accepting registrations.');
}
$festivalEvent = $event->isSubEvent() ? $event->parent : $event;
if ($festivalEvent->isFestival() || $festivalEvent->hasChildren()) {
// Festival: get child event sections only (skip parent operational sections)
$childIds = Event::where('parent_event_id', $festivalEvent->id)->pluck('id');
$sections = FestivalSection::whereIn('event_id', $childIds)
->where('show_in_registration', true)
->where('type', 'standard')
->select('id', 'name', 'category', 'icon', 'registration_description')
->orderBy('category')
->orderBy('sort_order')
->get()
->unique('name')
->values();
} else {
// Flat event: all sections of the event
$sections = FestivalSection::where('event_id', $festivalEvent->id)
->where('show_in_registration', true)
->where('type', 'standard')
->select('id', 'name', 'category', 'icon', 'registration_description')
->orderBy('category')
->orderBy('sort_order')
->get();
}
$timeSlots = $festivalEvent->getAllRelevantTimeSlots()
->where('person_type', 'VOLUNTEER')
->values();
return response()->json([
'data' => [
'event' => [
'id' => $festivalEvent->id,
'name' => $festivalEvent->name,
'start_date' => $festivalEvent->start_date->toDateString(),
'end_date' => $festivalEvent->end_date->toDateString(),
'organisation_id' => $festivalEvent->organisation_id,
'registration_banner_url' => $festivalEvent->registration_banner_url,
'registration_welcome_text' => $festivalEvent->registration_welcome_text,
'registration_logo_url' => $festivalEvent->registration_logo_url,
],
'sections' => $sections->map(fn (FestivalSection $section) => [
'id' => $section->id,
'name' => $section->name,
'category' => $section->category,
'icon' => $section->icon,
'registration_description' => $section->registration_description,
]),
'time_slots' => $timeSlots->map(fn (TimeSlot $slot) => [
'id' => $slot->id,
'name' => $slot->name,
'date' => $slot->date->toDateString(),
'start_time' => $slot->start_time,
'end_time' => $slot->end_time,
'duration_hours' => $slot->duration_hours,
]),
],
]);
}
}