<?php

namespace Database\Factories;

use App\Enums\IsActive;
use App\Models\Classification;
use App\Models\SubClassification;
use Illuminate\Database\Eloquent\Factories\Factory;

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

    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
            'classification_id' => Classification::factory(),
            'name' => $this->faker->words(2, true),
            'description' => $this->faker->sentence(),
            'is_active' => $this->faker->randomElement([IsActive::ACTIVE->value, IsActive::INACTIVE->value]),
            'sort_order' => $this->faker->numberBetween(0, 100),
        ];
    }

    /**
     * Indicate that the sub classification is active.
     */
    public function active(): static
    {
        return $this->state(fn (array $attributes) => [
            'is_active' => IsActive::ACTIVE->value,
        ]);
    }

    /**
     * Indicate that the sub classification is inactive.
     */
    public function inactive(): static
    {
        return $this->state(fn (array $attributes) => [
            'is_active' => IsActive::INACTIVE->value,
        ]);
    }
}
