<?php

namespace Database\Factories;

use App\Models\Province;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;

/**
 * @extends Factory<User>
 */
class UserFactory extends Factory
{
    public function definition(): array
    {
        return [
            'full_name' => $this->faker->name(),
            'username' => $this->faker->userName(),
            'position' => $this->faker->randomElement(['boss', 'operator']),
            'gender' => $this->faker->randomElement(['female', 'male']),
            'national_id' => $this->faker->unique()->numerify('##########'),
            'phone_number' => '09' . $this->faker->unique()->randomNumber(9, true),
            'province_id' => Province::factory(),
            'province_fa' => function (array $attributes) {
                return Province::query()->find($attributes['province_id'])->name;
            },
            'password' => Hash::make('password'),
            'email' => $this->faker->email,
            'telephone_id' => $this->faker->unique()->numerify('tel-####')
        ];
    }
}
