*/ class ServiceFactory extends Factory { protected $model = Service::class; /** * @return array */ public function definition(): array { $title = fake()->unique()->randomElement([ 'Desarrollo web', 'Acompañamiento técnico', 'Formación', 'Auditoría de accesibilidad', 'Infraestructura', 'Diseño de producto', ]).' '.fake()->unique()->numberBetween(1, 999); return [ 'title' => $this->eachLocale(fn (string $l) => "{$title} ({$l})"), 'slug' => $this->eachLocale(fn (string $l) => Str::slug("{$title}-{$l}")), 'tagline' => $this->eachLocale(fn () => fake()->sentence(8)), 'description' => $this->eachLocale(fn () => fake()->paragraph()), 'icon' => 'heroicon-o-code-bracket', 'is_published' => true, 'is_featured' => false, 'position' => 0, ]; } public function draft(): static { return $this->state(fn () => ['is_published' => false]); } public function featured(): static { return $this->state(fn () => ['is_featured' => true]); } /** @return array */ protected function eachLocale(callable $value): array { return collect(array_keys(config('locales.supported'))) ->mapWithKeys(fn (string $l) => [$l => $value($l)]) ->all(); } }