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>
This commit is contained in:
47
database/factories/CategoryFactory.php
Normal file
47
database/factories/CategoryFactory.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Category;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<Category>
|
||||
*/
|
||||
class CategoryFactory extends Factory
|
||||
{
|
||||
protected $model = Category::class;
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$name = $this->faker->unique()->words(2, true);
|
||||
|
||||
return [
|
||||
// Every supported locale gets a value so factory-made records
|
||||
// exercise the translation paths rather than the fallback.
|
||||
'name' => $this->eachLocale(fn (string $locale) => ucfirst($name)." ({$locale})"),
|
||||
'slug' => $this->eachLocale(fn (string $locale) => Str::slug($name."-{$locale}")),
|
||||
'description' => $this->eachLocale(fn () => $this->faker->sentence()),
|
||||
'color' => $this->faker->hexColor(),
|
||||
'position' => $this->faker->numberBetween(0, 20),
|
||||
'is_visible' => true,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param callable(string): string $value
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function eachLocale(callable $value): array
|
||||
{
|
||||
return collect(array_keys(config('locales.supported')))
|
||||
->mapWithKeys(fn (string $locale) => [$locale => $value($locale)])
|
||||
->all();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user