pp-planer/database/factories/ServiceAgendaItemFactory.php

52 lines
1.6 KiB
PHP

<?php
namespace Database\Factories;
use App\Models\Service;
use App\Models\ServiceAgendaItem;
use App\Models\ServiceSong;
use Illuminate\Database\Eloquent\Factories\Factory;
class ServiceAgendaItemFactory extends Factory
{
protected $model = ServiceAgendaItem::class;
public function definition(): array
{
return [
'service_id' => Service::factory(),
'cts_agenda_item_id' => $this->faker->uuid(),
'position' => $this->faker->numerify('#.#'),
'title' => $this->faker->sentence(3),
'type' => $this->faker->randomElement(['Song', 'Default', 'Header']),
'note' => $this->faker->optional()->sentence(),
'duration' => $this->faker->optional()->numerify('#'),
'start' => $this->faker->optional()->time(),
'is_before_event' => false,
'responsible' => $this->faker->optional()->randomElements(
['person1', 'person2', 'person3'],
$this->faker->numberBetween(1, 2)
),
'service_song_id' => null,
'sort_order' => $this->faker->numberBetween(1, 20),
];
}
public function withSong(ServiceSong $serviceSong): self
{
return $this->state(fn () => [
'service_song_id' => $serviceSong->id,
'service_id' => $serviceSong->service_id,
'type' => 'Song',
]);
}
public function nonSong(): self
{
return $this->state(fn () => [
'service_song_id' => null,
'type' => $this->faker->randomElement(['Default', 'Header']),
]);
}
}