*/ class UserFactory extends Factory { protected $model = User::class; /** * The current password being used by the 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), 'department_id' => Department::factory(), 'locale' => 'en', ]; } public function unverified(): static { return $this->state(fn (array $attributes): array => [ 'email_verified_at' => null, ]); } public function withoutDepartment(): static { return $this->state(fn (array $attributes): array => [ 'department_id' => null, ]); } }