2024-05-13 18:55:34 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Database\Factories;
|
|
|
|
|
2024-09-11 23:08:58 -04:00
|
|
|
use App\Models\User;
|
2024-05-13 18:55:34 -04:00
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
2024-09-11 23:08:58 -04:00
|
|
|
/**
|
|
|
|
* @extends Factory<User>
|
|
|
|
*/
|
2024-05-13 18:55:34 -04:00
|
|
|
class UserFactory extends Factory
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The current password being used by the factory.
|
|
|
|
*/
|
|
|
|
protected static ?string $password;
|
|
|
|
|
2024-09-11 23:08:58 -04:00
|
|
|
protected $model = User::class;
|
|
|
|
|
2024-05-13 18:55:34 -04:00
|
|
|
/**
|
2024-06-18 00:41:12 -04:00
|
|
|
* Define the user's default state.
|
2024-05-13 18:55:34 -04:00
|
|
|
*/
|
|
|
|
public function definition(): array
|
|
|
|
{
|
|
|
|
return [
|
2024-07-03 17:47:02 -04:00
|
|
|
'name' => fake()->userName(),
|
2024-05-13 18:55:34 -04:00
|
|
|
'email' => fake()->unique()->safeEmail(),
|
|
|
|
'email_verified_at' => now(),
|
|
|
|
'password' => static::$password ??= Hash::make('password'),
|
|
|
|
'two_factor_secret' => null,
|
|
|
|
'two_factor_recovery_codes' => null,
|
|
|
|
'remember_token' => Str::random(10),
|
2024-06-18 00:41:12 -04:00
|
|
|
'user_role_id' => null,
|
2024-05-13 18:55:34 -04:00
|
|
|
'profile_photo_path' => null,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-06-18 00:41:12 -04:00
|
|
|
* Indicate that the user's email address should be unverified.
|
2024-05-13 18:55:34 -04:00
|
|
|
*/
|
|
|
|
public function unverified(): static
|
|
|
|
{
|
|
|
|
return $this->state(fn (array $attributes) => [
|
|
|
|
'email_verified_at' => null,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|