Files
landing-api/database/factories/MemberFactory.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

70 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Models\Member;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<Member>
*/
class MemberFactory extends Factory
{
protected $model = Member::class;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
$name = fake()->name();
$handle = Str::slug($name).fake()->unique()->numberBetween(1, 9999);
return [
'user_id' => null,
'name' => $name,
'slug' => $handle,
'headline' => $this->eachLocale(fn (string $l) => fake()->jobTitle()." ({$l})"),
'bio' => $this->eachLocale(fn () => fake()->paragraph()),
'github_username' => $handle,
'links' => [
'github' => "https://github.com/{$handle}",
'website' => fake()->optional()->url(),
],
'is_public' => true,
'is_founder' => false,
'joined_at' => fake()->dateTimeBetween('-4 years'),
'position' => fake()->numberBetween(0, 20),
];
}
public function founder(): static
{
return $this->state(fn () => ['is_founder' => true]);
}
/**
* Someone who has moved on. Their work stays on the site.
*/
public function past(): static
{
return $this->state(fn () => ['left_at' => fake()->dateTimeBetween('-1 year')]);
}
public function hidden(): static
{
return $this->state(fn () => ['is_public' => false]);
}
/** @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();
}
}