<?php

declare(strict_types=1);

namespace Database\Factories;

use App\Models\Location;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

/**
 * Test data only.
 *
 * @extends Factory<Location>
 */
class LocationFactory extends Factory
{
    // The return shape is inherited from Factory<Location>::definition().
    public function definition(): array
    {
        $city = fake()->randomElement(['Pune', 'Bangalore', 'Mumbai', 'Hyderabad', 'Chennai']);

        return [
            'name' => $city.' Office '.Str::upper(Str::random(3)),
            'code' => Str::upper(Str::random(4)),
            'address_line1' => fake()->streetAddress(),
            'address_line2' => null,
            'city' => $city,
            'state' => fake()->randomElement(['Maharashtra', 'Karnataka', 'Telangana', 'Tamil Nadu']),
            'country' => 'India',
            'postal_code' => (string) fake()->numberBetween(110001, 799999),
            'is_active' => true,
        ];
    }

    public function inactive(): static
    {
        return $this->state(fn (array $attributes): array => [
            'is_active' => false,
        ]);
    }

    public function remote(): static
    {
        return $this->state(fn (array $attributes): array => [
            'name' => 'Remote — WFH '.Str::upper(Str::random(3)),
            'address_line1' => null,
            'city' => null,
            'state' => null,
            'postal_code' => null,
        ]);
    }
}
