presseportale/database/factories/UserFactory.php
Kevin Adametz e457e7a81c Profilfeld users.agency_name für Übermittler-Attribution
Erster Schritt des Umbaus Agentur-Attribution → User-Profil
(dev/agentur-attribution/entwicklungsplan.md, A1): Die Übermittler-
Angabe wird Profil-Eigenschaft des einliefernden Accounts statt
Pseudo-Firma vom Typ „agency".

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-08 09:20:32 +00:00

58 lines
1.6 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 withAgency(string $agencyName = 'Muster Presseverteiler'): static
{
return $this->state(['agency_name' => $agencyName]);
}
public function inactive(): static
{
return $this->state(['is_active' => false]);
}
public function superAdmin(): static
{
return $this->state(['is_super_admin' => true]);
}
}