Implement EAV system for dynamic event-specific registration fields with organisation-level templates, person section preferences with priority ranking, and TagSyncService for deferred tag_picker sync. New tables: registration_field_templates, registration_form_fields, person_field_values, person_section_preferences. New columns: persons.remarks, events.registration_show_section_preferences, events.registration_show_availability. 58 tests, 126 assertions — all 432 tests pass (zero regressions). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
63 lines
2.2 KiB
PHP
63 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers\Api\V1;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Api\V1\StoreRegistrationFieldTemplateRequest;
|
|
use App\Http\Requests\Api\V1\UpdateRegistrationFieldTemplateRequest;
|
|
use App\Http\Resources\Api\V1\RegistrationFieldTemplateResource;
|
|
use App\Models\Organisation;
|
|
use App\Models\RegistrationFieldTemplate;
|
|
use App\Services\RegistrationFieldTemplateService;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
final class RegistrationFieldTemplateController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly RegistrationFieldTemplateService $service,
|
|
) {}
|
|
|
|
public function index(Organisation $organisation): AnonymousResourceCollection
|
|
{
|
|
Gate::authorize('viewAny', [RegistrationFieldTemplate::class, $organisation]);
|
|
|
|
$templates = $this->service->listForOrganisation($organisation);
|
|
|
|
return RegistrationFieldTemplateResource::collection($templates);
|
|
}
|
|
|
|
public function store(StoreRegistrationFieldTemplateRequest $request, Organisation $organisation): JsonResponse
|
|
{
|
|
Gate::authorize('create', [RegistrationFieldTemplate::class, $organisation]);
|
|
|
|
$template = $this->service->createTemplate($organisation, $request->validated());
|
|
|
|
return $this->created(new RegistrationFieldTemplateResource($template));
|
|
}
|
|
|
|
public function update(
|
|
UpdateRegistrationFieldTemplateRequest $request,
|
|
Organisation $organisation,
|
|
RegistrationFieldTemplate $registrationFieldTemplate,
|
|
): JsonResponse {
|
|
Gate::authorize('update', [$registrationFieldTemplate, $organisation]);
|
|
|
|
$template = $this->service->updateTemplate($registrationFieldTemplate, $request->validated());
|
|
|
|
return $this->success(new RegistrationFieldTemplateResource($template));
|
|
}
|
|
|
|
public function destroy(Organisation $organisation, RegistrationFieldTemplate $registrationFieldTemplate): JsonResponse
|
|
{
|
|
Gate::authorize('delete', [$registrationFieldTemplate, $organisation]);
|
|
|
|
$this->service->deleteTemplate($registrationFieldTemplate);
|
|
|
|
return response()->json(null, 204);
|
|
}
|
|
}
|