*/ class CmsReferenceFactory extends Factory { protected $model = CmsReference::class; public function definition(): array { $title = fake()->unique()->words(3, true); return [ 'title' => ['de' => ucfirst($title), 'en' => ucfirst($title)], 'location' => fake()->city(), 'year' => (string) fake()->numberBetween(2022, 2026), 'description' => ['de' => fake()->paragraph(2), 'en' => fake()->paragraph(2)], 'image' => 'referenzen/'.fake()->unique()->slug(2).'.webp', 'gallery' => [], 'brand_slugs' => [], 'is_published' => true, 'order' => fake()->numberBetween(1, 20), ]; } public function published(): static { return $this->state(fn () => ['is_published' => true]); } public function unpublished(): static { return $this->state(fn () => ['is_published' => false]); } /** * @param list $slugs */ public function forBrands(array $slugs): static { return $this->state(fn () => ['brand_slugs' => $slugs]); } public function withGallery(int $count = 2): static { return $this->state(function () use ($count) { $items = []; for ($i = 1; $i <= $count; $i++) { $items[] = ['image' => 'referenzen/bild-'.$i.'.webp', 'caption' => 'Bild '.$i]; } return ['gallery' => $items]; }); } }