ldc-crm/database/factories/UserFactory.php

44 lines
1.2 KiB
PHP
Raw Normal View History

2020-12-01 17:02:10 +01:00
<?php
namespace Database\Factories;
2023-10-06 15:00:42 +02:00
use App\Enums\Users\RoleEnum;
2020-12-01 17:02:10 +01:00
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class UserFactory extends Factory
{
/**
* Define the model's default state.
*
2023-10-06 15:00:42 +02:00
* @return array<string, mixed>
2020-12-01 17:02:10 +01:00
*/
public function definition()
{
2023-10-06 15:00:42 +02:00
$published = $this->faker->boolean(75);
2020-12-01 17:02:10 +01:00
return [
2023-10-06 15:00:42 +02:00
'first_name' => fake()->firstname(),
'last_name' => fake()->lastname(),
'email' => fake()->unique()->safeEmail(),
2020-12-01 17:02:10 +01:00
'email_verified_at' => now(),
2023-10-06 15:00:42 +02:00
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi',
'remember_token' => Str::random(10),
'role' => \collect(RoleEnum::toArray())->random()->value,
'published' => $published,
'published_at' => ($published) ? now() : null,
2020-12-01 17:02:10 +01:00
];
}
2023-10-06 15:00:42 +02:00
/**
* Indicate that the model's email address should be unverified.
*
* @return static
*/
public function unverified(): static
{
2024-09-09 15:26:35 +02:00
return $this->state(fn() => [
2023-10-06 15:00:42 +02:00
'email_verified_at' => null,
]);
}
2020-12-01 17:02:10 +01:00
}