53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?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');
|
|
}
|
|
}
|