S2a: purge legacy Form Builder PHP code and routes

This commit is contained in:
2026-04-17 18:43:00 +02:00
parent cfc7610497
commit a3ca596362
55 changed files with 128 additions and 6057 deletions

View File

@@ -1,97 +0,0 @@
<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Enums\FieldDisplayWidth;
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_categories' => null,
'is_required' => false,
'is_filterable' => false,
'is_portal_visible' => true,
'is_admin_only' => false,
'help_text' => null,
'sort_order' => fake()->numberBetween(0, 20),
'display_width' => FieldDisplayWidth::FULL,
'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,
'display_width' => FieldDisplayWidth::HALF,
]);
}
public function booleanField(): static
{
return $this->state(fn () => [
'label' => 'EHBO / BHV diploma',
'slug' => 'ehbo-bhv-diploma',
'field_type' => RegistrationFieldType::BOOLEAN,
'is_filterable' => true,
'display_width' => FieldDisplayWidth::HALF,
]);
}
public function tagPickerField(): static
{
return $this->state(fn () => [
'label' => 'Certificaten & vaardigheden',
'slug' => 'certificaten-vaardigheden',
'field_type' => RegistrationFieldType::TAG_PICKER,
'is_filterable' => true,
'display_width' => FieldDisplayWidth::FULL,
]);
}
public function headingField(): static
{
return $this->state(fn () => [
'label' => 'Persoonlijke voorkeuren',
'slug' => 'persoonlijke-voorkeuren',
'field_type' => RegistrationFieldType::HEADING,
'help_text' => 'Vertel ons wat we over jou moeten weten',
'display_width' => FieldDisplayWidth::FULL,
]);
}
}

View File

@@ -1,133 +0,0 @@
<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Enums\FieldDisplayWidth;
use App\Enums\RegistrationFieldType;
use App\Models\Event;
use App\Models\RegistrationFormField;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/** @extends Factory<RegistrationFormField> */
final class RegistrationFormFieldFactory extends Factory
{
protected $model = RegistrationFormField::class;
/** @return array<string, mixed> */
public function definition(): array
{
$label = fake('nl_NL')->unique()->words(2, true);
return [
'event_id' => Event::factory(),
'label' => ucfirst($label),
'slug' => Str::slug($label),
'field_type' => RegistrationFieldType::TEXT,
'options' => null,
'tag_categories' => null,
'is_required' => false,
'is_portal_visible' => true,
'is_admin_only' => false,
'is_filterable' => false,
'help_text' => null,
'sort_order' => fake()->numberBetween(0, 20),
'display_width' => FieldDisplayWidth::FULL,
];
}
public function textField(): static
{
return $this->state(fn () => [
'label' => 'Noodcontact naam',
'slug' => 'noodcontact-naam',
'field_type' => RegistrationFieldType::TEXT,
'display_width' => FieldDisplayWidth::HALF,
]);
}
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,
'display_width' => FieldDisplayWidth::HALF,
]);
}
public function multiselectField(): static
{
return $this->state(fn () => [
'label' => 'Dieetwensen',
'slug' => 'dieetwensen',
'field_type' => RegistrationFieldType::MULTISELECT,
'options' => ['Vegetarisch', 'Veganistisch', 'Halal', 'Glutenvrij', 'Lactosevrij', 'Geen pinda\'s', 'Geen noten'],
'is_filterable' => true,
'display_width' => FieldDisplayWidth::FULL,
]);
}
public function booleanField(): static
{
return $this->state(fn () => [
'label' => 'Toestemming gegevensverwerking',
'slug' => 'toestemming-gegevensverwerking',
'field_type' => RegistrationFieldType::BOOLEAN,
'is_required' => true,
'help_text' => 'Ik geef toestemming voor de verwerking van mijn persoonsgegevens conform de AVG.',
'display_width' => FieldDisplayWidth::FULL,
]);
}
public function tagPickerField(): static
{
return $this->state(fn () => [
'label' => 'Vaardigheden',
'slug' => 'vaardigheden',
'field_type' => RegistrationFieldType::TAG_PICKER,
'is_filterable' => true,
'display_width' => FieldDisplayWidth::FULL,
]);
}
public function radioField(): static
{
return $this->state(fn () => [
'label' => 'Vergoeding',
'slug' => 'vergoeding',
'field_type' => RegistrationFieldType::RADIO,
'options' => [
['label' => 'Pro Deo', 'description' => 'Je werkt als vrijwilliger zonder financiële vergoeding'],
['label' => 'Entreeticket', 'description' => 'Je ontvangt een gratis festivalticket als dank voor je inzet'],
['label' => 'Vrijwilligersvergoeding', 'description' => 'Je ontvangt een vergoeding conform de vrijwilligersregeling'],
],
'display_width' => FieldDisplayWidth::FULL,
]);
}
public function textareaField(): static
{
return $this->state(fn () => [
'label' => 'Opmerkingen',
'slug' => 'opmerkingen',
'field_type' => RegistrationFieldType::TEXTAREA,
'display_width' => FieldDisplayWidth::FULL,
]);
}
public function headingField(): static
{
return $this->state(fn () => [
'label' => 'Persoonlijke voorkeuren',
'slug' => 'persoonlijke-voorkeuren',
'field_type' => RegistrationFieldType::HEADING,
'help_text' => 'Vertel ons wat we over jou moeten weten',
'display_width' => FieldDisplayWidth::FULL,
]);
}
}

View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
/**
* S2a drops the three remaining legacy registration tables now that every
* PHP caller (controllers / services / requests / resources / policies /
* models / tests) has been purged. The forms:migrate-legacy-data command
* self-skips when these tables are absent, so environments with real
* legacy data can still run the migration command BEFORE running this
* drop migration to move their data onto the new form_* tables.
*
* down() is a hard failure: restoring these tables and repopulating them
* from the new form_* structure would be a lossy, non-trivial conversion
* and there is no supported path back. Use migrate:fresh + restore from
* backup if you genuinely need the legacy state.
*/
return new class extends Migration
{
public function up(): void
{
// person_field_values has a FK to registration_form_fields; drop
// it first to avoid constraint ordering issues.
Schema::dropIfExists('person_field_values');
Schema::dropIfExists('registration_form_fields');
Schema::dropIfExists('registration_field_templates');
}
public function down(): void
{
throw new \RuntimeException(
'Legacy registration tables cannot be restored. Use migrate:fresh '
.'or restore from a pre-S2a backup.'
);
}
};

View File

@@ -21,11 +21,10 @@ use App\Models\Person;
use Illuminate\Support\Str;
/**
* Seeds the form-builder layer for DevSeeder. Replaces the legacy
* RegistrationFieldTemplateService::seedSystemTemplates call produces 16
* system form_templates per org, one FormSchema per event, canonical 16
* fields per schema, and a realistic set of FormSubmissions for
* approved/applied/no_show persons (matching the migration command rule).
* Seeds the form-builder layer for DevSeeder: 16 system form_templates per
* org, one FormSchema per event, the canonical 16-field registration set,
* and a realistic batch of FormSubmissions for approved/applied/no_show
* persons (same rule as the forms:migrate-legacy-data command).
*
* Callers MUST wrap this in ActivityLog::suppressed() every field create
* would otherwise fire a logFieldChange("created") entry.