Files
eCert-MBIP/database/factories/UserFactory.php
Saufi 700fbd1bcc feat: testing suite and bug fixes (Fasa 11)
- AuthTest, ProgramTest, CheckinTest, QuestionnaireTest, CertificateTest — 19 feature tests, 35 total pass
- ProgramFactory with published() state
- UserFactory: is_admin=true default, nonAdmin() state
- Fix attendance_source column name in StatisticsController (was: source)
- Fix route(dashboard) → route(admin.dashboard) in all Breeze auth controllers
- Remove irrelevant Breeze boilerplate tests (Profile, Example, Registration)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 00:23:38 +08:00

49 lines
1.1 KiB
PHP

<?php
namespace Database\Factories;
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
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
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),
'is_admin' => true,
];
}
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
public function nonAdmin(): static
{
return $this->state(fn (array $attributes) => ['is_admin' => false]);
}
}