*/ class UserFactory extends Factory { protected static ?string $password; /** * @return array */ 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), 'role' => UserRole::Assistant, 'is_active' => true, ]; } public function admin(): static { return $this->state(fn (array $attributes): array => [ 'role' => UserRole::Admin, ]); } public function assistant(): static { return $this->state(fn (array $attributes): array => [ 'role' => UserRole::Assistant, ]); } public function inactive(): static { return $this->state(fn (array $attributes): array => [ 'is_active' => false, ]); } public function unverified(): static { return $this->state(fn (array $attributes): array => [ 'email_verified_at' => null, ]); } }