42 lines
915 B
PHP
42 lines
915 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\User;
|
|
use App\Enums\Users\RoleEnum;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
class UserFactory extends Factory
|
|
{
|
|
/**
|
|
* The name of the factory's corresponding model.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $model = User::class;
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'name' => fake()->name(),
|
|
'email' => fake()->unique()->safeEmail(),
|
|
'role' => RoleEnum::developper,
|
|
'gitlab_id' => fake()->optional()->randomNumber(5),
|
|
'favourite_site_id' => null,
|
|
];
|
|
}
|
|
|
|
public function admin(): static
|
|
{
|
|
return $this->state(fn(array $attributes) => [
|
|
'role' => RoleEnum::admin,
|
|
]);
|
|
}
|
|
}
|