<?php

namespace Database\Seeders;

use App\Models\Tier;
use App\Models\Website;
use Illuminate\Database\Seeder;

class WebsiteSeeder extends Seeder
{
    public function run(): void
    {
        $basicTier = Tier::where('slug', 'basic')->first();
        $standardTier = Tier::where('slug', 'standard')->first();
        $premiumTier = Tier::where('slug', 'premium')->first();

        $basicWebsite = Website::create([
            'name' => 'Car Service Basic',
            'domain' => 'car-service-basic.test',
            'tier_id' => $basicTier->id,
            'cache_hit_rate_limit' => 100,
            'external_api_rate_limit' => 10,
            'is_active' => true,
            'bypass_rate_limit' => false,
        ]);

        $standardWebsite = Website::create([
            'name' => 'Car Service Standard',
            'domain' => 'car-service-standard.test',
            'tier_id' => $standardTier->id,
            'cache_hit_rate_limit' => 200,
            'external_api_rate_limit' => 20,
            'is_active' => true,
            'bypass_rate_limit' => false,
        ]);

        $premiumWebsite = Website::create([
            'name' => 'Car Service Premium',
            'domain' => 'car-service-premium.test',
            'tier_id' => $premiumTier->id,
            'cache_hit_rate_limit' => 500,
            'external_api_rate_limit' => 50,
            'is_active' => true,
            'bypass_rate_limit' => false,
        ]);

        $devWebsite = Website::create([
            'name' => 'Development Testing',
            'domain' => 'dev.test',
            'tier_id' => $premiumTier->id,
            'cache_hit_rate_limit' => 1000,
            'external_api_rate_limit' => 100,
            'is_active' => true,
            'bypass_rate_limit' => true,
        ]);

        $basicToken = $basicWebsite->createToken('api-token')->plainTextToken;
        $standardToken = $standardWebsite->createToken('api-token')->plainTextToken;
        $premiumToken = $premiumWebsite->createToken('api-token')->plainTextToken;
        $devToken = $devWebsite->createToken('api-token')->plainTextToken;

        $this->command->info('Websites seeded successfully!');
        $this->command->newLine();
        $this->command->info('Basic Tier Token: '.$basicToken);
        $this->command->info('Standard Tier Token: '.$standardToken);
        $this->command->info('Premium Tier Token: '.$premiumToken);
        $this->command->info('Development Token: '.$devToken);
    }
}
