feat(form-builder): form_field_configs relational table + non-validation key split + drop validation_rules JSON columns
This commit is contained in:
@@ -51,7 +51,6 @@ final class FormField extends Model
|
||||
'help_text',
|
||||
'section',
|
||||
'options',
|
||||
'validation_rules',
|
||||
'is_required',
|
||||
'is_filterable',
|
||||
'is_portal_visible',
|
||||
@@ -70,7 +69,6 @@ final class FormField extends Model
|
||||
/** @var array<string, string> */
|
||||
protected $casts = [
|
||||
'options' => 'array',
|
||||
'validation_rules' => 'array',
|
||||
'conditional_logic' => 'array',
|
||||
'role_restrictions' => 'array',
|
||||
'translations' => 'array',
|
||||
@@ -116,6 +114,11 @@ final class FormField extends Model
|
||||
return $this->morphMany(FormFieldValidationRule::class, 'owner');
|
||||
}
|
||||
|
||||
public function configs(): MorphMany
|
||||
{
|
||||
return $this->morphMany(FormFieldConfig::class, 'owner');
|
||||
}
|
||||
|
||||
/**
|
||||
* Nuanced activity log (ARCH §17.1; S1 Phase 4b). Callers choose which
|
||||
* events are worth logging — e.g. created/deleted/restored, field_type
|
||||
|
||||
52
api/app/Models/FormBuilder/FormFieldConfig.php
Normal file
52
api/app/Models/FormBuilder/FormFieldConfig.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models\FormBuilder;
|
||||
|
||||
use App\Enums\FormBuilder\FormFieldConfigType;
|
||||
use App\Models\Scopes\FormFieldConfigScope;
|
||||
use Illuminate\Database\Eloquent\Concerns\HasUlids;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
/**
|
||||
* Relational home for non-validation field configuration. See
|
||||
* ARCH-FORM-BUILDER §17.5 and ARCH-CONSOLIDATION-ADDENDUM-2026-04-24
|
||||
* §Q3 WS-5b Uitvoering.
|
||||
*
|
||||
* Polymorphic owner (`form_field` / `form_field_library` aliases, reused
|
||||
* from WS-5a). One row per (owner, config_type). Parameter shape
|
||||
* validated at the service layer.
|
||||
*/
|
||||
final class FormFieldConfig extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasUlids;
|
||||
|
||||
protected $table = 'form_field_configs';
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::addGlobalScope(new FormFieldConfigScope());
|
||||
}
|
||||
|
||||
protected $fillable = [
|
||||
'owner_type',
|
||||
'owner_id',
|
||||
'config_type',
|
||||
'parameters',
|
||||
];
|
||||
|
||||
/** @var array<string, string> */
|
||||
protected $casts = [
|
||||
'config_type' => FormFieldConfigType::class,
|
||||
'parameters' => 'array',
|
||||
];
|
||||
|
||||
public function owner(): MorphTo
|
||||
{
|
||||
return $this->morphTo('owner', 'owner_type', 'owner_id');
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,6 @@ final class FormFieldLibrary extends Model
|
||||
'label',
|
||||
'help_text',
|
||||
'options',
|
||||
'validation_rules',
|
||||
'default_is_required',
|
||||
'default_is_filterable',
|
||||
'translations',
|
||||
@@ -46,7 +45,6 @@ final class FormFieldLibrary extends Model
|
||||
/** @var array<string, string> */
|
||||
protected $casts = [
|
||||
'options' => 'array',
|
||||
'validation_rules' => 'array',
|
||||
'translations' => 'array',
|
||||
'default_is_required' => 'bool',
|
||||
'default_is_filterable' => 'bool',
|
||||
@@ -74,4 +72,9 @@ final class FormFieldLibrary extends Model
|
||||
{
|
||||
return $this->morphMany(FormFieldValidationRule::class, 'owner');
|
||||
}
|
||||
|
||||
public function configs(): MorphMany
|
||||
{
|
||||
return $this->morphMany(FormFieldConfig::class, 'owner');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user