refactor(form-builder): drop custom purpose escape from schemas
Reduces the FormPurpose vocabulary from 22 variants + a `custom` escape to the seven v1.0 purposes registered in the new PurposeRegistry. - Purge migration deletes any form_schemas row whose `purpose` is not in the v1.0 set (cascades through form_fields, form_submissions, form_values, form_value_options, form_schema_sections, form_submission_section_statuses, form_submission_delegations, form_schema_webhooks, form_webhook_deliveries via existing FK). - Drop migration removes the `custom_purpose_slug` column + its index. - Both migrations declare their `down()` as a hard failure — we do not support reversing a purge (pre-launch, no production data). - `FormPurpose` enum slims to the seven cases; the legacy helpers (defaultSubmissionMode / defaultSubjectType / allowsPublicAccess) now delegate to PurposeRegistry so callers keep working. - FormSchema fillable / FormSchemaResource / StoreFormSchemaRequest / UpdateFormSchemaRequest / FormSchemaFactory drop every reference to `custom_purpose_slug` and the `custom` purpose. - VerifyFormsDataIntegrity drops the custom-slug mismatch check and sources the subject-type allow-list from PurposeRegistry. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,6 @@ namespace Database\Factories\FormBuilder;
|
||||
|
||||
use App\Enums\FormBuilder\FormPurpose;
|
||||
use App\Enums\FormBuilder\FormSchemaSnapshotMode;
|
||||
use App\Enums\FormBuilder\FormSubmissionMode;
|
||||
use App\Models\FormBuilder\FormSchema;
|
||||
use App\Models\Organisation;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
@@ -22,9 +21,9 @@ final class FormSchemaFactory extends Factory
|
||||
{
|
||||
$purpose = fake()->randomElement([
|
||||
FormPurpose::EVENT_REGISTRATION,
|
||||
FormPurpose::FEEDBACK,
|
||||
FormPurpose::INCIDENT_REPORT,
|
||||
FormPurpose::USER_PROFILE,
|
||||
FormPurpose::POST_EVENT_EVALUATION,
|
||||
]);
|
||||
$name = 'Formulier '.fake('nl_NL')->words(2, true);
|
||||
|
||||
@@ -35,7 +34,6 @@ final class FormSchemaFactory extends Factory
|
||||
'name' => $name,
|
||||
'slug' => Str::slug($name).'-'.Str::lower(Str::random(4)),
|
||||
'purpose' => $purpose,
|
||||
'custom_purpose_slug' => null,
|
||||
'description' => fake('nl_NL')->sentence(),
|
||||
'is_published' => false,
|
||||
'submission_mode' => $purpose->defaultSubmissionMode(),
|
||||
@@ -48,15 +46,6 @@ final class FormSchemaFactory extends Factory
|
||||
];
|
||||
}
|
||||
|
||||
public function custom(string $slug): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'purpose' => FormPurpose::CUSTOM,
|
||||
'submission_mode' => FormSubmissionMode::SINGLE,
|
||||
'custom_purpose_slug' => $slug,
|
||||
]);
|
||||
}
|
||||
|
||||
public function published(): static
|
||||
{
|
||||
return $this->state(fn () => ['is_published' => true]);
|
||||
@@ -67,7 +56,6 @@ final class FormSchemaFactory extends Factory
|
||||
return $this->state(fn () => [
|
||||
'purpose' => $purpose,
|
||||
'submission_mode' => $purpose->defaultSubmissionMode(),
|
||||
'custom_purpose_slug' => $purpose === FormPurpose::CUSTOM ? 'custom-'.Str::lower(Str::random(6)) : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user