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>
56 lines
1.6 KiB
PHP
56 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Enums\FormBuilder;
|
|
|
|
/**
|
|
* v1.0 purpose vocabulary — the seven purposes registered in
|
|
* `config/form_builder/purposes.php` (ARCH-CONSOLIDATION §3 besluit 4).
|
|
*
|
|
* Prefer `App\FormBuilder\Purposes\PurposeRegistry` for lookups: label,
|
|
* subject_type, default submission mode, public-access flag and
|
|
* required bindings all live there. This enum is kept for type-safety
|
|
* on the `form_schemas.purpose` column and for code paths that match
|
|
* a purpose by identity.
|
|
*/
|
|
enum FormPurpose: string
|
|
{
|
|
case EVENT_REGISTRATION = 'event_registration';
|
|
case ARTIST_ADVANCE = 'artist_advance';
|
|
case SUPPLIER_INTAKE = 'supplier_intake';
|
|
case POST_EVENT_EVALUATION = 'post_event_evaluation';
|
|
case INCIDENT_REPORT = 'incident_report';
|
|
case SIGNATURE_CONTRACT = 'signature_contract';
|
|
case USER_PROFILE = 'user_profile';
|
|
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
public static function values(): array
|
|
{
|
|
return array_map(fn (self $case): string => $case->value, self::cases());
|
|
}
|
|
|
|
public function defaultSubmissionMode(): FormSubmissionMode
|
|
{
|
|
return app(\App\FormBuilder\Purposes\PurposeRegistry::class)
|
|
->get($this->value)
|
|
->defaultSubmissionMode;
|
|
}
|
|
|
|
public function defaultSubjectType(): string
|
|
{
|
|
return app(\App\FormBuilder\Purposes\PurposeRegistry::class)
|
|
->get($this->value)
|
|
->subjectType;
|
|
}
|
|
|
|
public function allowsPublicAccess(): bool
|
|
{
|
|
return app(\App\FormBuilder\Purposes\PurposeRegistry::class)
|
|
->get($this->value)
|
|
->allowsPublicAccess;
|
|
}
|
|
}
|