Laravel 13 + Filament 5 admin panel and REST API for a non-profit developer collective, backed by the Pireon OAuth identity server. The public site is a separate, server-rendered application consuming /api/public/v1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
58 lines
1.6 KiB
PHP
58 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Service;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @extends Factory<Service>
|
|
*/
|
|
class ServiceFactory extends Factory
|
|
{
|
|
protected $model = Service::class;
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
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<string, string> */
|
|
protected function eachLocale(callable $value): array
|
|
{
|
|
return collect(array_keys(config('locales.supported')))
|
|
->mapWithKeys(fn (string $l) => [$l => $value($l)])
|
|
->all();
|
|
}
|
|
}
|