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>
83 lines
2.3 KiB
PHP
83 lines
2.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\RegistrationFieldType;
|
|
use App\Models\Organisation;
|
|
use App\Models\RegistrationFieldTemplate;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
|
|
/** @extends Factory<RegistrationFieldTemplate> */
|
|
final class RegistrationFieldTemplateFactory extends Factory
|
|
{
|
|
protected $model = RegistrationFieldTemplate::class;
|
|
|
|
/** @return array<string, mixed> */
|
|
public function definition(): array
|
|
{
|
|
$label = fake('nl_NL')->unique()->words(2, true);
|
|
|
|
return [
|
|
'organisation_id' => Organisation::factory(),
|
|
'label' => ucfirst($label),
|
|
'slug' => Str::slug($label),
|
|
'field_type' => RegistrationFieldType::TEXT,
|
|
'options' => null,
|
|
'tag_category' => null,
|
|
'is_required' => false,
|
|
'is_filterable' => false,
|
|
'is_portal_visible' => true,
|
|
'is_admin_only' => false,
|
|
'section' => null,
|
|
'help_text' => null,
|
|
'sort_order' => fake()->numberBetween(0, 20),
|
|
'is_system' => false,
|
|
'is_active' => true,
|
|
];
|
|
}
|
|
|
|
public function system(): static
|
|
{
|
|
return $this->state(fn () => ['is_system' => true]);
|
|
}
|
|
|
|
public function inactive(): static
|
|
{
|
|
return $this->state(fn () => ['is_active' => false]);
|
|
}
|
|
|
|
public function selectField(): static
|
|
{
|
|
return $this->state(fn () => [
|
|
'label' => 'Shirtmaat',
|
|
'slug' => 'shirtmaat',
|
|
'field_type' => RegistrationFieldType::SELECT,
|
|
'options' => ['XS', 'S', 'M', 'L', 'XL', 'XXL', 'XXXL'],
|
|
'is_filterable' => true,
|
|
]);
|
|
}
|
|
|
|
public function booleanField(): static
|
|
{
|
|
return $this->state(fn () => [
|
|
'label' => 'EHBO / BHV diploma',
|
|
'slug' => 'ehbo-bhv-diploma',
|
|
'field_type' => RegistrationFieldType::BOOLEAN,
|
|
'is_filterable' => true,
|
|
]);
|
|
}
|
|
|
|
public function tagPickerField(): static
|
|
{
|
|
return $this->state(fn () => [
|
|
'label' => 'Certificaten & vaardigheden',
|
|
'slug' => 'certificaten-vaardigheden',
|
|
'field_type' => RegistrationFieldType::TAG_PICKER,
|
|
'is_filterable' => true,
|
|
]);
|
|
}
|
|
}
|