41 lines
1.0 KiB
PHP
41 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\Gender;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
|
|
class UserFactory extends Factory
|
|
{
|
|
protected $model = User::class;
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$faker = $this->faker;
|
|
return [
|
|
'address' => $faker->address,
|
|
'birthday' => $faker->dateTimeBetween('-30 years', '-10 years'),
|
|
'name' => $faker->name,
|
|
'password' => '$10$MXFSBvoV02d.nMg/5//5ru/os27JgSJhsePidDr/uiIw6UQ.MigP2',
|
|
'phone' => $faker->phoneNumber,
|
|
'sex' => $faker->randomElement(array_keys(Gender::map()))
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Indicate that the model's email address should be unverified.
|
|
*/
|
|
public function unverified(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'email_verified_at' => null,
|
|
]);
|
|
}
|
|
}
|