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:
59
database/factories/UserFactory.php
Normal file
59
database/factories/UserFactory.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Default state mirrors what the OAuth callback produces: an identity
|
||||
* copied from the server, with no local password.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'oauth_id' => fake()->unique()->numberBetween(1000, 999999),
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => null,
|
||||
'locale' => fake()->randomElement(array_keys(config('locales.supported'))),
|
||||
'is_active' => true,
|
||||
'remote_roles' => ['user'],
|
||||
'last_login_at' => now(),
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
public function inactive(): static
|
||||
{
|
||||
return $this->state(fn () => ['is_active' => false]);
|
||||
}
|
||||
|
||||
/**
|
||||
* A user who has never signed in through the identity server, used to
|
||||
* check that the callback adopts pre-existing local rows by email.
|
||||
*/
|
||||
public function unlinked(): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'oauth_id' => null,
|
||||
'last_login_at' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function withRole(string $role): static
|
||||
{
|
||||
return $this->afterCreating(fn (User $user) => $user->assignRole($role));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user