53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\Portal;
|
|
use App\Enums\RegistrationType;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @extends Factory<User>
|
|
*/
|
|
class UserFactory extends Factory
|
|
{
|
|
protected static ?string $password;
|
|
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'name' => fake()->name(),
|
|
'email' => fake()->unique()->safeEmail(),
|
|
'email_verified_at' => now(),
|
|
'password' => static::$password ??= Hash::make('password'),
|
|
'remember_token' => Str::random(10),
|
|
// Felder aus expand_users_table_for_migration_2026 explizit setzen,
|
|
// da DB-Defaults nicht automatisch in Model-Attribute übernommen werden.
|
|
'portal' => Portal::Both->value,
|
|
'registration_type' => RegistrationType::ExistingLegacy->value,
|
|
'language' => 'de',
|
|
'is_active' => true,
|
|
'is_super_admin' => false,
|
|
];
|
|
}
|
|
|
|
public function unverified(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'email_verified_at' => null,
|
|
]);
|
|
}
|
|
|
|
public function inactive(): static
|
|
{
|
|
return $this->state(['is_active' => false]);
|
|
}
|
|
|
|
public function superAdmin(): static
|
|
{
|
|
return $this->state(['is_super_admin' => true]);
|
|
}
|
|
}
|