<?php

declare(strict_types=1);

namespace Database\Factories;

use App\Models\PlanConfigGroup;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<PlanConfigGroup>
 */
class PlanConfigGroupFactory extends Factory
{
    protected $model = PlanConfigGroup::class;

    /** @return array<string, mixed> */
    public function definition(): array
    {
        return [
            'name' => fake()->words(3, true),
            'description' => fake()->sentence(),
            'mode' => 'preset',
            'service_type' => fake()->randomElement(['vps', 'dedicated', 'hosting', 'game']),
            'is_active' => true,
            'sort_order' => fake()->numberBetween(0, 100),
        ];
    }

    public function buildYourOwn(?string $serviceType = null): static
    {
        return $this->state(fn (array $attributes) => [
            'mode' => 'build_your_own',
            'service_type' => $serviceType ?? $attributes['service_type'],
        ]);
    }

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