Files
landing-api/database/factories/TechnologyFactory.php
Josep Piguillem 3897113313 Initial commit: Pireon Admin — headless admin panel and public API
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>
2026-08-19 17:55:27 +02:00

61 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Enums\RadarRing;
use App\Enums\TechnologyCategory;
use App\Models\Technology;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<Technology>
*/
class TechnologyFactory extends Factory
{
protected $model = Technology::class;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
$name = fake()->unique()->randomElement([
'Laravel', 'Astro', 'PHP', 'TypeScript', 'Rust', 'Go', 'PostgreSQL',
'Redis', 'Docker', 'Tailwind CSS', 'Vue', 'Svelte', 'Python',
'Kubernetes', 'Terraform', 'Elasticsearch', 'RabbitMQ', 'Vite',
]).' '.fake()->unique()->numberBetween(1, 9999);
return [
'name' => $name,
'slug' => Str::slug($name),
'description' => $this->eachLocale(fn () => fake()->sentence()),
'radar_note' => $this->eachLocale(fn () => fake()->sentence(10)),
'category' => fake()->randomElement(TechnologyCategory::cases()),
'radar_ring' => fake()->randomElement(RadarRing::cases()),
'color' => fake()->hexColor(),
'position' => fake()->numberBetween(0, 30),
];
}
public function offRadar(): static
{
return $this->state(fn () => ['radar_ring' => null]);
}
public function ring(RadarRing $ring): static
{
return $this->state(fn () => ['radar_ring' => $ring]);
}
/** @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();
}
}