2026-05-08 09:37:16 +03:00
|
|
|
<?php
|
|
|
|
|
|
2026-05-08 14:29:50 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-05-08 09:37:16 +03:00
|
|
|
namespace Database\Factories;
|
|
|
|
|
|
2026-05-08 14:29:50 +03:00
|
|
|
use App\Models\Tenant;
|
2026-05-08 09:37:16 +03:00
|
|
|
use App\Models\User;
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @extends Factory<User>
|
|
|
|
|
*/
|
|
|
|
|
class UserFactory extends Factory
|
|
|
|
|
{
|
2026-05-08 14:29:50 +03:00
|
|
|
protected static ?string $password = null;
|
2026-05-08 09:37:16 +03:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return array<string, mixed>
|
|
|
|
|
*/
|
|
|
|
|
public function definition(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
2026-05-08 14:29:50 +03:00
|
|
|
'tenant_id' => Tenant::factory(),
|
2026-05-08 09:37:16 +03:00
|
|
|
'email' => fake()->unique()->safeEmail(),
|
2026-05-08 14:29:50 +03:00
|
|
|
'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,
|
2026-05-08 09:37:16 +03:00
|
|
|
'email_verified_at' => now(),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function unverified(): static
|
|
|
|
|
{
|
|
|
|
|
return $this->state(fn (array $attributes) => [
|
|
|
|
|
'email_verified_at' => null,
|
|
|
|
|
]);
|
|
|
|
|
}
|
2026-05-08 14:29:50 +03:00
|
|
|
|
|
|
|
|
public function inactive(): static
|
|
|
|
|
{
|
|
|
|
|
return $this->state(fn (array $attributes) => [
|
|
|
|
|
'is_active' => false,
|
|
|
|
|
]);
|
|
|
|
|
}
|
2026-05-08 09:37:16 +03:00
|
|
|
}
|