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>
This commit is contained in:
@@ -30,6 +30,8 @@ final class EventResource extends JsonResource
|
||||
'registration_banner_url' => $this->registration_banner_url,
|
||||
'registration_welcome_text' => $this->registration_welcome_text,
|
||||
'registration_logo_url' => $this->registration_logo_url,
|
||||
'registration_show_section_preferences' => $this->registration_show_section_preferences,
|
||||
'registration_show_availability' => $this->registration_show_availability,
|
||||
'is_festival' => $this->resource->isFestival(),
|
||||
'is_sub_event' => $this->resource->isSubEvent(),
|
||||
'is_flat_event' => $this->resource->isFlatEvent(),
|
||||
|
||||
34
api/app/Http/Resources/Api/V1/PersonFieldValueResource.php
Normal file
34
api/app/Http/Resources/Api/V1/PersonFieldValueResource.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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 PersonFieldValueResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$field = $this->registrationFormField;
|
||||
|
||||
return [
|
||||
'field_slug' => $field?->slug,
|
||||
'field_label' => $field?->label,
|
||||
'field_type' => $field?->field_type?->value,
|
||||
'value' => $this->value,
|
||||
'selected_options' => $this->selected_options,
|
||||
'tag_names' => $this->when(
|
||||
$field?->field_type === RegistrationFieldType::TAG_PICKER && !empty($this->selected_options),
|
||||
function () {
|
||||
return PersonTag::whereIn('id', $this->selected_options ?? [])
|
||||
->pluck('name')
|
||||
->all();
|
||||
}
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ final class PersonResource extends JsonResource
|
||||
'status' => $this->status,
|
||||
'is_blacklisted' => $this->is_blacklisted,
|
||||
'admin_notes' => $this->admin_notes,
|
||||
'remarks' => $this->remarks,
|
||||
'custom_fields' => $this->custom_fields,
|
||||
'created_at' => $this->created_at->toIso8601String(),
|
||||
'crowd_type' => new CrowdTypeResource($this->whenLoaded('crowdType')),
|
||||
@@ -53,6 +54,8 @@ final class PersonResource extends JsonResource
|
||||
'added_by_user_id' => $this->pivot->added_by_user_id,
|
||||
]
|
||||
),
|
||||
'field_values' => PersonFieldValueResource::collection($this->whenLoaded('fieldValues')),
|
||||
'section_preferences' => PersonSectionPreferenceResource::collection($this->whenLoaded('sectionPreferences')),
|
||||
'tags' => $this->when(
|
||||
$this->user_id && $this->relationLoaded('user'),
|
||||
function () {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources\Api\V1;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
final class PersonSectionPreferenceResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$section = $this->whenLoaded('festivalSection');
|
||||
|
||||
return [
|
||||
'festival_section_id' => $this->festival_section_id,
|
||||
'priority' => $this->priority,
|
||||
'section_name' => $this->when(
|
||||
$this->relationLoaded('festivalSection'),
|
||||
fn () => $this->festivalSection?->name
|
||||
),
|
||||
'section_icon' => $this->when(
|
||||
$this->relationLoaded('festivalSection'),
|
||||
fn () => $this->festivalSection?->icon
|
||||
),
|
||||
'section_category' => $this->when(
|
||||
$this->relationLoaded('festivalSection'),
|
||||
fn () => $this->festivalSection?->category
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources\Api\V1;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
final class RegistrationFieldTemplateResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'organisation_id' => $this->organisation_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_filterable' => $this->is_filterable,
|
||||
'is_portal_visible' => $this->is_portal_visible,
|
||||
'is_admin_only' => $this->is_admin_only,
|
||||
'section' => $this->section,
|
||||
'help_text' => $this->help_text,
|
||||
'sort_order' => $this->sort_order,
|
||||
'is_system' => $this->is_system,
|
||||
'is_active' => $this->is_active,
|
||||
'created_at' => $this->created_at->toIso8601String(),
|
||||
'updated_at' => $this->updated_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?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());
|
||||
}
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user