2FAuth/database/factories/UserFactory.php

60 lines
1.4 KiB
PHP
Raw Normal View History

2019-05-20 07:37:41 +02:00
<?php
2021-12-02 13:15:53 +01:00
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
2019-05-20 07:37:41 +02:00
use Illuminate\Support\Str;
2022-11-21 11:16:43 +01:00
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
2021-12-02 13:15:53 +01:00
class UserFactory extends Factory
{
const USER_PASSWORD = 'password';
2021-12-02 13:15:53 +01:00
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->name(),
'email' => $this->faker->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => bcrypt(self::USER_PASSWORD),
2021-12-02 13:15:53 +01:00
'remember_token' => Str::random(10),
'is_admin' => false,
2021-12-02 13:15:53 +01:00
];
}
2019-05-20 07:37:41 +02:00
/**
* Indicate that the user is an administrator.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
public function administrator()
{
return $this->state(function (array $attributes) {
return [
'is_admin' => true,
];
});
}
2021-12-02 13:15:53 +01:00
/**
* Indicate that the model's email address should be unverified.
*
2022-11-21 11:16:43 +01:00
* @return \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
2021-12-02 13:15:53 +01:00
*/
public function unverified()
{
return $this->state(function (array $attributes) {
return [
'email_verified_at' => null,
];
});
}
}