<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\Plan;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class RefactoredSubscriptionPlanSeeder extends Seeder
{
    public function run()
    {
        // Disable foreign key checks to allow truncation (SQLite compatible)
        Schema::disableForeignKeyConstraints();
        Plan::truncate();
        Schema::enableForeignKeyConstraints();

        // 1. Free Plan
        Plan::create([
            'name' => 'Free Plan',
            'slug' => 'free-plan',
            'duration_days' => 365, // Valid for a year (or considered unlimited)
            'price_inr' => 0.00,
            'price_usd' => 0.00,
            'product_limit' => 3,
            'inquiry_limit' => 0, // Assuming limited or none
            'product_image_limit' => 2,
            'banner_limit' => 0,
            'is_active' => true,
            'is_featured' => false,
            'features' => [
                '3 Product Listing',
                'limited Buyer Notification',
                'Contact Details Hidden',
                '2 Images per Product'
            ]
        ]);

        // 2. Basic Monthly
        Plan::create([
            'name' => 'Basic Plan - Monthly',
            'slug' => 'basic-monthly',
            'duration_days' => 30,
            'price_inr' => 350.00,
            'price_usd' => 6.00,
            'product_limit' => 10,
            'inquiry_limit' => 10,
            'product_image_limit' => 4,
            'banner_limit' => 0,
            'is_active' => true,
            'is_featured' => false,
            'features' => [
                '10 Product Listing',
                '10 Buyer Notification via Email',
                'Basic Support',
                'Contact Details visible to Buyer',
                '4 Images per Product',
                'Buyer can easily contact via contact no. or email',
                'Send Inquiry Button Active'
            ]
        ]);

        // 3. Basic Quarterly
        Plan::create([
            'name' => 'Basic Plan - 3 Months',
            'slug' => 'basic-quarterly',
            'duration_days' => 90,
            'price_inr' => 999.00,
            'price_usd' => 15.00,
            'product_limit' => 30,
            'inquiry_limit' => 30,
            'product_image_limit' => 4,
            'banner_limit' => 0,
            'is_active' => true,
            'is_featured' => true,
            'features' => [
                '30 Product Listing',
                '30 Buyer Notification via Email',
                'Basic Support',
                'Contact Details visible to Buyer',
                '4 Images per Product',
                'Buyer can easily contact via contact no. or email',
                'Send Inquiry Button Active'
            ]
        ]);

        // 4. Silver Monthly
        Plan::create([
            'name' => 'Silver Plan - Monthly',
            'slug' => 'silver-monthly',
            'duration_days' => 30,
            'price_inr' => 600.00,
            'price_usd' => 12.00,
            'product_limit' => 20,
            'inquiry_limit' => 20,
            'product_image_limit' => 4,
            'banner_limit' => 0,
            'is_active' => true,
            'is_featured' => false,
            'features' => [
                '20 Product Listing',
                '20 Buyer Notification via Email',
                'Basic Support',
                'Product Details & Contact Info visible',
                '4 Images per Product',
                'Buyer can easily contact via contact no. or email',
                'Send Inquiry Button Active'
            ]
        ]);

        // 5. Silver Quarterly
        Plan::create([
            'name' => 'Silver Plan - 3 Months',
            'slug' => 'silver-quarterly',
            'duration_days' => 90,
            'price_inr' => 1699.00,
            'price_usd' => 32.00,
            'product_limit' => 60,
            'inquiry_limit' => 60,
            'product_image_limit' => 4,
            'banner_limit' => 0,
            'is_active' => true,
            'is_featured' => false,
            'features' => [
                '60 Product Listing',
                '60 Buyer Notification via Email',
                'Basic Support',
                'Product Details & Contact Info visible',
                '4 Images per Product',
                'Buyer can easily contact via contact no. or email',
                'Send Inquiry Button Active'
            ]
        ]);

        $this->command->info('Refactored Plans (Free + Basic/Silver) Seeded Successfully.');
    }
}
