Add fakers for fields

This commit is contained in:
philipp lang 2023-12-27 22:39:23 +01:00
parent d4c8fdff3f
commit d597d5ea2b
6 changed files with 22 additions and 6 deletions

View File

@ -26,6 +26,9 @@ class CheckboxField extends Field
public static function fake(Generator $faker): array
{
return [];
return [
'description' => $faker->text(),
'required' => $faker->boolean(),
];
}
}

View File

@ -25,6 +25,8 @@ class CheckboxesField extends Field
public static function fake(Generator $faker): array
{
return [];
return [
'options' => $faker->words(4),
];
}
}

View File

@ -26,6 +26,9 @@ class DropdownField extends Field
public static function fake(Generator $faker): array
{
return [];
return [
'options' => $faker->words(4),
'required' => $faker->boolean(),
];
}
}

View File

@ -26,6 +26,9 @@ class RadioField extends Field
public static function fake(Generator $faker): array
{
return [];
return [
'options' => $faker->words(4),
'required' => $faker->boolean(),
];
}
}

View File

@ -26,6 +26,9 @@ class TextareaField extends Field
public static function fake(Generator $faker): array
{
return [];
return [
'rows' => $faker->numberBetween(5, 10),
'required' => $faker->boolean(),
];
}
}

View File

@ -22,12 +22,14 @@ class FormtemplateFieldRequest extends RequestFactory
*/
public function definition(): array
{
$type = $this->faker->randomElement(array_column(Field::asMeta(), 'id'));
return [
'name' => $this->faker->words(5, true),
'key' => str($this->faker->words(5, true))->snake()->toString(),
'type' => $this->faker->randomElement(array_column(Field::asMeta(), 'id')),
'type' => $type,
'columns' => ['mobile' => 2, 'tablet' => 4, 'desktop' => 6],
'default' => '',
...Field::classFromType($type)::fake($this->faker),
];
}