<?php

namespace Database\Factories;

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

/**
 * @extends Factory<Product>
 */
class ProductFactory extends Factory
{
    public function definition(): array
    {
        $name = fake()->words(3, true);

        return [
            'category_id' => Category::factory(),
            'name' => $name,
            'slug' => Str::slug($name),
            'price' => fake()->randomFloat(2, 10, 500),
            'price_unit' => fake()->randomElement(['kg', 'sany', 'gram']),
            'description' => fake()->sentence(12),
            'image' => null,
            'availability_status' => 'available',
            'is_active' => true,
            'sort_order' => fake()->numberBetween(0, 10),
        ];
    }

    public function unavailable(): static
    {
        return $this->state(['availability_status' => 'out_of_season']);
    }

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