<?php

namespace Database\Factories;

use App\Enums\IsActive;
use App\Models\Location;
use App\Models\SubLocation;
use Illuminate\Database\Eloquent\Factories\Factory;

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

    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
            'location_id' => Location::factory(),
            'name' => $this->faker->streetName(),
            '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 location is active.
     */
    public function active(): static
    {
        return $this->state(fn (array $attributes) => [
            'is_active' => IsActive::ACTIVE->value,
        ]);
    }

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