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>
72 lines
1.7 KiB
PHP
72 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\RegistrationFieldType;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Concerns\HasUlids;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
final class RegistrationFieldTemplate extends Model
|
|
{
|
|
use HasFactory;
|
|
use HasUlids;
|
|
|
|
protected $fillable = [
|
|
'organisation_id',
|
|
'label',
|
|
'slug',
|
|
'field_type',
|
|
'options',
|
|
'tag_category',
|
|
'is_required',
|
|
'is_filterable',
|
|
'is_portal_visible',
|
|
'is_admin_only',
|
|
'section',
|
|
'help_text',
|
|
'sort_order',
|
|
'is_system',
|
|
'is_active',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'field_type' => RegistrationFieldType::class,
|
|
'options' => 'array',
|
|
'is_required' => 'boolean',
|
|
'is_filterable' => 'boolean',
|
|
'is_portal_visible' => 'boolean',
|
|
'is_admin_only' => 'boolean',
|
|
'sort_order' => 'integer',
|
|
'is_system' => 'boolean',
|
|
'is_active' => 'boolean',
|
|
];
|
|
}
|
|
|
|
public function organisation(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Organisation::class);
|
|
}
|
|
|
|
public function scopeActive(Builder $query): Builder
|
|
{
|
|
return $query->where('is_active', true);
|
|
}
|
|
|
|
public function scopeSystem(Builder $query): Builder
|
|
{
|
|
return $query->where('is_system', true);
|
|
}
|
|
|
|
public function scopeOrdered(Builder $query): Builder
|
|
{
|
|
return $query->orderBy('sort_order');
|
|
}
|
|
}
|