<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\Plan;

class SubscriptionPlanSeeder extends Seeder
{
    public function run()
    {
        // Clear existing plans to avoid duplicates and remove old ones
        // Disable foreign key checks to allow truncation
        \Illuminate\Support\Facades\Schema::disableForeignKeyConstraints();
        Plan::truncate();
        \Illuminate\Support\Facades\Schema::enableForeignKeyConstraints(); 

        $plans = [
            [
                'name' => 'Silver Growth',
                'price_inr' => 4999,
                'price_usd' => 69,
                'duration_days' => 365,
                'product_limit' => 50,
                'product_image_limit' => 5, // Max 5 images
                'inquiry_limit' => 100,
                'features' => ['Email Support', 'Buyer Contact Access'],
                'is_active' => true,
                'show_contact_details' => true, // Buyers can see seller contact
                'view_buyer_contact' => true,   // Seller can see buyer contact
                'is_featured' => false,
                'has_verified_badge' => false,
                'allow_microsite' => false,
                'commission_rate' => 5.00, // 5% Commission
            ],
            [
                'name' => 'Platinum Enterprise',
                'price_inr' => 49999,
                'price_usd' => 599,
                'duration_days' => 365,
                'product_limit' => 10000, // Unlimited effectively
                'product_image_limit' => 20, // Max 20 images
                'inquiry_limit' => 10000,
                'features' => ['Dedicated Manager', 'Microsite', '0% Commission', 'Top Search Ranking'],
                'is_active' => true,
                'show_contact_details' => true,
                'view_buyer_contact' => true,
                'is_featured' => true,
                'has_verified_badge' => true,
                'allow_microsite' => true, // Custom Website
                'commission_rate' => 0.00, // 0% Commission
            ],
        ];

        foreach ($plans as $plan) {
            Plan::updateOrCreate(
                ['name' => $plan['name']], // Check by name to avoid duplicates
                $plan
            );
        }
    }
}
