*/ final class FormFieldFactory extends Factory { protected $model = FormField::class; /** @return array */ public function definition(): array { $fieldType = fake()->randomElement([ FormFieldType::TEXT, FormFieldType::TEXTAREA, FormFieldType::EMAIL, FormFieldType::NUMBER, FormFieldType::BOOLEAN, FormFieldType::SELECT, ]); $label = fake('nl_NL')->randomElement([ 'Voornaam', 'Achternaam', 'E-mail', 'Telefoon', 'Opmerkingen', 'Shirtmaat', 'Allergieën', 'Motivatie', 'Geboortedatum', ]); return [ 'form_schema_id' => FormSchema::factory(), 'form_schema_section_id' => null, 'library_field_id' => null, 'field_type' => $fieldType->value, 'slug' => Str::slug($label).'-'.Str::lower(Str::random(4)), 'label' => $label, 'help_text' => fake()->boolean(30) ? fake('nl_NL')->sentence() : null, '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, 'is_admin_only' => false, 'is_unique' => false, 'is_pii' => false, 'display_width' => FormFieldDisplayWidth::FULL, 'binding' => null, 'conditional_logic' => null, 'role_restrictions' => null, 'translations' => null, 'value_storage_hint' => $fieldType->recommendedValueStorageHint(), 'review_required' => false, 'sort_order' => 0, ]; } public function ofType(FormFieldType $type): static { return $this->state(fn () => [ 'field_type' => $type->value, 'value_storage_hint' => $type->recommendedValueStorageHint(), ]); } public function filterable(): static { return $this->state(fn () => ['is_filterable' => true]); } }