<?php

namespace Database\Factories;

use App\Models\Company;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Company>
 */
class CompanyFactory extends Factory
{
    protected $model = Company::class;

    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
            'user_id' => User::factory(),
            'name' => $this->faker->company(),
            'email' => $this->faker->unique()->companyEmail(),
            'address' => $this->faker->address(),
            'director_name' => $this->faker->name(),
            'director_nik' => $this->faker->numerify('################'),
            'deed_incorporation' => $this->faker->numerify('AHU-#######.AH.##.##'),
            'trade_license' => $this->faker->numerify('###/###/SIUP/####'),
            'tax_id_number' => $this->faker->numerify('##.###.###.#-###.###'),
            'taxable_enterprise' => $this->faker->numerify('###.###.###.###'),
            'annual_tax_return' => $this->faker->numerify('SPT-####-########'),
            'domicile_certificate' => $this->faker->numerify('###/###/DOMISILI/####'),
            'profile' => $this->faker->numerify('PROFILE-####-########'),
            'validated_at' => $this->faker->optional(0.7)->dateTimeBetween('-1 year', 'now'),
            'rejection_reason' => $this->faker->optional(0.1)->sentence(),
        ];
    }

    /**
     * Indicate that the company is validated.
     */
    public function validated(): static
    {
        return $this->state(fn (array $attributes) => [
            'validated_at' => $this->faker->dateTimeBetween('-6 months', 'now'),
            'rejection_reason' => null,
        ]);
    }

    /**
     * Indicate that the company is rejected.
     */
    public function rejected(): static
    {
        return $this->state(fn (array $attributes) => [
            'validated_at' => null,
            'rejection_reason' => $this->faker->sentence(),
        ]);
    }

    /**
     * Indicate that the company is pending validation.
     */
    public function pending(): static
    {
        return $this->state(fn (array $attributes) => [
            'validated_at' => null,
            'rejection_reason' => null,
        ]);
    }
}
