Files
crewli/api/database/factories/RegistrationFormFieldFactory.php
bert.hausmans 6a8d21a5b6 feat: registration field polish, multi-category tags, file uploads, Partner icon
- Restructure field editor dialog: move Options section to bottom with
  divider and subheader, fix delete button with flex layout
- Change tag_category (single string) to tag_categories (JSON array)
  supporting multiple category selection in tag picker fields
- Portal tag picker now groups tags by category with subheaders
- Add generic file upload endpoint (FileUploadService + UploadController)
- Replace email branding logo URL text field with ImageUploadField
- Update Partner crowd type default icon to tabler-affiliate
- Apply changes consistently to both field and template dialogs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 18:03:49 +02:00

134 lines
4.5 KiB
PHP

<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Enums\FieldDisplayWidth;
use App\Enums\RegistrationFieldType;
use App\Models\Event;
use App\Models\RegistrationFormField;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/** @extends Factory<RegistrationFormField> */
final class RegistrationFormFieldFactory extends Factory
{
protected $model = RegistrationFormField::class;
/** @return array<string, mixed> */
public function definition(): array
{
$label = fake('nl_NL')->unique()->words(2, true);
return [
'event_id' => Event::factory(),
'label' => ucfirst($label),
'slug' => Str::slug($label),
'field_type' => RegistrationFieldType::TEXT,
'options' => null,
'tag_categories' => null,
'is_required' => false,
'is_portal_visible' => true,
'is_admin_only' => false,
'is_filterable' => false,
'help_text' => null,
'sort_order' => fake()->numberBetween(0, 20),
'display_width' => FieldDisplayWidth::FULL,
];
}
public function textField(): static
{
return $this->state(fn () => [
'label' => 'Noodcontact naam',
'slug' => 'noodcontact-naam',
'field_type' => RegistrationFieldType::TEXT,
'display_width' => FieldDisplayWidth::HALF,
]);
}
public function selectField(): static
{
return $this->state(fn () => [
'label' => 'Shirtmaat',
'slug' => 'shirtmaat',
'field_type' => RegistrationFieldType::SELECT,
'options' => ['XS', 'S', 'M', 'L', 'XL', 'XXL', 'XXXL'],
'is_filterable' => true,
'display_width' => FieldDisplayWidth::HALF,
]);
}
public function multiselectField(): static
{
return $this->state(fn () => [
'label' => 'Dieetwensen',
'slug' => 'dieetwensen',
'field_type' => RegistrationFieldType::MULTISELECT,
'options' => ['Vegetarisch', 'Veganistisch', 'Halal', 'Glutenvrij', 'Lactosevrij', 'Geen pinda\'s', 'Geen noten'],
'is_filterable' => true,
'display_width' => FieldDisplayWidth::FULL,
]);
}
public function booleanField(): static
{
return $this->state(fn () => [
'label' => 'Toestemming gegevensverwerking',
'slug' => 'toestemming-gegevensverwerking',
'field_type' => RegistrationFieldType::BOOLEAN,
'is_required' => true,
'help_text' => 'Ik geef toestemming voor de verwerking van mijn persoonsgegevens conform de AVG.',
'display_width' => FieldDisplayWidth::FULL,
]);
}
public function tagPickerField(): static
{
return $this->state(fn () => [
'label' => 'Vaardigheden',
'slug' => 'vaardigheden',
'field_type' => RegistrationFieldType::TAG_PICKER,
'is_filterable' => true,
'display_width' => FieldDisplayWidth::FULL,
]);
}
public function radioField(): static
{
return $this->state(fn () => [
'label' => 'Vergoeding',
'slug' => 'vergoeding',
'field_type' => RegistrationFieldType::RADIO,
'options' => [
['label' => 'Pro Deo', 'description' => 'Je werkt als vrijwilliger zonder financiële vergoeding'],
['label' => 'Entreeticket', 'description' => 'Je ontvangt een gratis festivalticket als dank voor je inzet'],
['label' => 'Vrijwilligersvergoeding', 'description' => 'Je ontvangt een vergoeding conform de vrijwilligersregeling'],
],
'display_width' => FieldDisplayWidth::FULL,
]);
}
public function textareaField(): static
{
return $this->state(fn () => [
'label' => 'Opmerkingen',
'slug' => 'opmerkingen',
'field_type' => RegistrationFieldType::TEXTAREA,
'display_width' => FieldDisplayWidth::FULL,
]);
}
public function headingField(): static
{
return $this->state(fn () => [
'label' => 'Persoonlijke voorkeuren',
'slug' => 'persoonlijke-voorkeuren',
'field_type' => RegistrationFieldType::HEADING,
'help_text' => 'Vertel ons wat we over jou moeten weten',
'display_width' => FieldDisplayWidth::FULL,
]);
}
}