adrema/database/factories/Form/Models/FormtemplateFactory.php

47 lines
1.0 KiB
PHP
Raw Normal View History

2023-12-26 00:44:49 +01:00
<?php
namespace Database\Factories\Form\Models;
use App\Form\Models\Formtemplate;
use Illuminate\Database\Eloquent\Factories\Factory;
2024-01-01 16:53:32 +01:00
use Tests\Feature\Form\FormtemplateSectionRequest;
2023-12-26 00:44:49 +01:00
/**
* @extends Factory<Formtemplate>
2024-01-01 16:53:32 +01:00
* @method self name(string $name)
2023-12-26 00:44:49 +01:00
*/
class FormtemplateFactory extends Factory
{
public $model = Formtemplate::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
return [
'name' => $this->faker->words(4, true),
'config' => [],
];
}
2024-01-01 16:53:32 +01:00
/**
* @param array<int, FormtemplateSectionRequest> $sections
*/
public function sections(array $sections): self
{
2024-01-10 21:31:34 +01:00
return $this->state(['config' => ['sections' => array_map(fn ($section) => $section->create(), $sections)]]);
2024-01-01 16:53:32 +01:00
}
/**
2024-01-10 21:31:34 +01:00
* @param mixed $parameters
2024-01-01 16:53:32 +01:00
*/
public function __call($method, $parameters): self
{
return $this->state([str($method)->snake()->toString() => $parameters[0]]);
}
2023-12-26 00:44:49 +01:00
}