ldc-nature-eleveurs/database/factories/UserFactory.php

30 lines
838 B
PHP
Raw Permalink Normal View History

2022-08-09 12:29:21 +00:00
<?php
namespace Database\Factories;
2024-01-31 16:42:01 +01:00
use App\Enums\Users\RoleEnum;
2022-08-09 12:29:21 +00:00
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class UserFactory extends Factory
{
/**
* Define the model's default state.
*
2024-01-31 16:42:01 +01:00
* @return array<string, mixed>
2022-08-09 12:29:21 +00:00
*/
2024-01-31 16:42:01 +01:00
public function definition(): array
2022-08-09 12:29:21 +00:00
{
2024-01-31 16:42:01 +01:00
$published = $this->faker->boolean(75);
2022-08-09 12:29:21 +00:00
return [
2024-01-31 16:42:01 +01:00
'first_name' => fake()->firstname(),
'last_name' => fake()->lastname(),
'email' => fake()->unique()->safeEmail(),
'remember_token' => Str::random(10),
'role' => \collect(RoleEnum::toArray())->random()->value,
'published' => $published,
'published_at' => ($published) ? now() : null,
2022-08-09 12:29:21 +00:00
];
}
}