Files
portal/app/database/factories/UserFactory.php
T

52 lines
1.2 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Models\Tenant;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
/**
* @extends Factory<User>
*/
class UserFactory extends Factory
{
protected static ?string $password = null;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'tenant_id' => Tenant::factory(),
'email' => fake()->unique()->safeEmail(),
'password_hash' => static::$password ??= Hash::make('password'),
'first_name' => fake()->firstName(),
'last_name' => fake()->lastName(),
'timezone' => 'Europe/Moscow',
'is_active' => true,
'totp_enabled' => false,
'sound_enabled' => true,
'email_verified_at' => now(),
];
}
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
public function inactive(): static
{
return $this->state(fn (array $attributes) => [
'is_active' => false,
]);
}
}