*/ class UserFactory extends Factory { /** * The current password being used by the factory. */ protected static ?string $password; /** * Define the model's default state. * * @return array */ public function definition(): array { return [ 'name' => fake()->name(), 'username' => fake()->unique()->userName(), 'email' => fake()->unique()->safeEmail(), 'email_verified_at' => now(), 'password' => static::$password ??= Hash::make('password'), 'role' => Role::Mahasiswa, 'is_active' => true, 'last_login_at' => null, 'remember_token' => Str::random(10), ]; } public function superuser(): static { return $this->state(['role' => Role::Superuser]); } public function admin(): static { return $this->state(['role' => Role::Admin]); } public function operator(): static { return $this->state(['role' => Role::Operator]); } public function dosen(): static { return $this->state(['role' => Role::Dosen]); } public function mahasiswa(): static { return $this->state(['role' => Role::Mahasiswa]); } /** Akun dinonaktifkan: tidak boleh masuk. */ public function inactive(): static { return $this->state(['is_active' => false]); } /** * Indicate that the model's email address should be unverified. */ public function unverified(): static { return $this->state(['email_verified_at' => null]); } }