Files
crewli/api/app/Http/Resources/Api/V1/RegistrationFormFieldResource.php
bert.hausmans f6e3568011 feat: registration form fields, section preferences, tag sync & schema updates
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>
2026-04-12 22:10:16 +02:00

49 lines
1.7 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Resources\Api\V1;
use App\Enums\RegistrationFieldType;
use App\Models\PersonTag;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
final class RegistrationFormFieldResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'event_id' => $this->event_id,
'label' => $this->label,
'slug' => $this->slug,
'field_type' => $this->field_type->value,
'options' => $this->options,
'tag_category' => $this->tag_category,
'is_required' => $this->is_required,
'is_portal_visible' => $this->is_portal_visible,
'is_admin_only' => $this->is_admin_only,
'is_filterable' => $this->is_filterable,
'section' => $this->section,
'help_text' => $this->help_text,
'sort_order' => $this->sort_order,
'created_at' => $this->created_at->toIso8601String(),
'updated_at' => $this->updated_at->toIso8601String(),
'available_tags' => $this->when(
$this->field_type === RegistrationFieldType::TAG_PICKER,
function () {
$query = PersonTag::where('organisation_id', $this->event->organisation_id)
->where('is_active', true);
if ($this->tag_category) {
$query->where('category', $this->tag_category);
}
return PersonTagResource::collection($query->orderBy('sort_order')->get());
}
),
];
}
}