<?php

namespace Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;

class UserFactory extends Factory
{
    public function definition(): array
    {
        return [
            'name'              => fake()->name(),
            'phone'             => '08' . fake()->numerify('#########'),
            'email'             => fake()->unique()->safeEmail(),
            'email_verified_at' => now(),
            'password'          => Hash::make('password'),
            'is_active'         => true,
        ];
    }

    /**
     * User customer (belum ada role, role di-assign di seeder).
     */
    public function customer(): static
    {
        return $this->state(fn () => [
            'email' => fake()->unique()->safeEmail(),
        ]);
    }

    /**
     * User admin operasional.
     */
    public function admin(): static
    {
        return $this->state(fn () => [
            'name'  => 'Admin ' . fake()->firstName(),
            'email' => 'admin_' . fake()->unique()->userName() . '@titipinbabe.com',
        ]);
    }

    /**
     * User tidak aktif.
     */
    public function inactive(): static
    {
        return $this->state(fn () => ['is_active' => false]);
    }
}
