<?php

namespace Database\Factories;

use App\Enums\OutletStatus;
use App\Models\Outlet;
use Illuminate\Database\Eloquent\Factories\Factory;

class OutletFactory extends Factory
{
    protected $model = Outlet::class;

    public function definition(): array
    {
        return [
            'name' => $this->faker->company(),
            'slug' => $this->faker->slug(),
            'phone_number' => $this->faker->randomElement([
                $this->faker->numerify('0812 #### ###'),
                $this->faker->numerify('0812 #### ####'),
                $this->faker->numerify('0812 #### #####'),
            ]),
            'address' => $this->faker->address(),
            'opened_date' => $this->faker->date(),
            'status' => $this->faker->randomElement(OutletStatus::cases()),
        ];
    }

    public function withLandmark(): Factory
    {
        return $this->state(fn () => ['landmark' => $this->faker->streetName()]);
    }

    public function withMapsUrl(): Factory
    {
        return $this->state(fn () => ['maps_url' => 'https://goo.gl/maps/'.$this->faker->regexify('[A-Za-z0-9]{6,10}')]);
    }

    public function closed(): Factory
    {
        return $this->state(fn () => ['closed_date' => $this->faker->date()]);
    }

    public function operational(): Factory
    {
        return $this->state(fn () => ['status' => OutletStatus::OPERATIONAL]);
    }

    public function underConstruction(): Factory
    {
        return $this->state(fn () => ['status' => OutletStatus::UNDER_CONSTRUCTION]);
    }

    public function terminated(): Factory
    {
        return $this->state(fn () => ['status' => OutletStatus::TERMINATED]);
    }
}
