<?php

declare(strict_types=1);

namespace Database\Factories;

use App\Domain\Package\Models\Package;
use App\Domain\Reseller\Models\ResellerSubPackage;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

/**
 * @extends Factory<ResellerSubPackage>
 */
class ResellerSubPackageFactory extends Factory
{
    protected $model = ResellerSubPackage::class;

    public function definition(): array
    {
        $name = $this->faker->words(2, true).' Plan';

        return [
            'reseller_user_id' => User::factory(),
            'parent_package_id' => Package::factory(),
            'name' => $name,
            'slug' => Str::slug($name),
            'limits' => [
                'disk_mb' => $this->faker->randomElement([1024, 5120, 10240]),
                'db_count' => $this->faker->numberBetween(1, 20),
                'domain_count' => $this->faker->numberBetween(1, 20),
                'addon_domain_count' => $this->faker->numberBetween(0, 10),
                'subdomain_count' => $this->faker->numberBetween(5, 50),
                'php_versions' => ['8.2', '8.3'],
            ],
            'reseller_price_try' => $this->faker->randomFloat(2, 10, 200),
            'is_active' => true,
            'display_order' => $this->faker->numberBetween(0, 20),
        ];
    }

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