pp-planer/database/factories/ServiceAgendaItemFactory.php
Thorsten Bus e489a984eb chore(deps): bump PHP to 8.4 and update propresenter/parser with Macro/Label support
- Raise PHP requirement from ^8.2 to ^8.4 (parser requires 8.4)
- New parser classes available: MacrosFileReader, LabelsFileReader,
  Macro, MacroLibrary, MacroCollection, Label, LabelLibrary
- Add programmatic test fixtures for macros-sample.bin + labels-sample.bin
- Fix ServiceAgendaItemFactory sort_order to auto-increment
2026-05-03 22:07:56 +02:00

54 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
{
private static int $nextSortOrder = 1;
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' => self::$nextSortOrder++,
];
}
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']),
]);
}
}