feat(form-builder): form_field_configs relational table + non-validation key split + drop validation_rules JSON columns
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories\FormBuilder;
|
||||
|
||||
use App\Enums\FormBuilder\FormFieldConfigType;
|
||||
use App\Models\FormBuilder\FormField;
|
||||
use App\Models\FormBuilder\FormFieldConfig;
|
||||
use App\Models\FormBuilder\FormFieldLibrary;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/** @extends Factory<FormFieldConfig> */
|
||||
final class FormFieldConfigFactory extends Factory
|
||||
{
|
||||
protected $model = FormFieldConfig::class;
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'owner_type' => 'form_field',
|
||||
'owner_id' => FormField::factory(),
|
||||
'config_type' => FormFieldConfigType::TagCategories->value,
|
||||
'parameters' => ['categories' => ['Veiligheid']],
|
||||
];
|
||||
}
|
||||
|
||||
public function forField(FormField $field): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'owner_type' => 'form_field',
|
||||
'owner_id' => $field->id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function forLibrary(FormFieldLibrary $library): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'owner_type' => 'form_field_library',
|
||||
'owner_id' => $library->id,
|
||||
]);
|
||||
}
|
||||
|
||||
/** @param array<string, mixed> $parameters */
|
||||
public function ofType(FormFieldConfigType $type, array $parameters): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'config_type' => $type->value,
|
||||
'parameters' => $parameters,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,6 @@ final class FormFieldFactory extends Factory
|
||||
'options' => $fieldType === FormFieldType::SELECT
|
||||
? ['Optie A', 'Optie B', 'Optie C']
|
||||
: null,
|
||||
'validation_rules' => null,
|
||||
'is_required' => fake()->boolean(40),
|
||||
'is_filterable' => false,
|
||||
'is_portal_visible' => true,
|
||||
|
||||
@@ -35,7 +35,6 @@ final class FormFieldLibraryFactory extends Factory
|
||||
'label' => fake('nl_NL')->words(2, true),
|
||||
'help_text' => null,
|
||||
'options' => null,
|
||||
'validation_rules' => null,
|
||||
'default_is_required' => false,
|
||||
'default_is_filterable' => false,
|
||||
'translations' => null,
|
||||
|
||||
Reference in New Issue
Block a user