<?php

namespace Database\Seeders;

use App\Models\Business;
use App\Models\Product;
use App\Models\Sale;
use App\Models\Repair;
use App\Models\SecondHand;
use App\Models\UnlockOrder;
use App\Models\BusinessPayment;
use Illuminate\Database\Seeder;

class SaaSSeeder extends Seeder
{
    public function run(): void
    {
        // Create demo business
        $business = Business::create([
            'shop_name' => 'Demo Mobile Shop',
            'phone_number' => '9800000000',
            'password' => 'password',
            'plan_type' => 'free',
            'plan_expiry_date' => today()->addDays(7),
            'plan_status' => 'active',
        ]);

        // Products
        $product = Product::create([
            'business_id' => $business->id,
            'name' => 'iPhone 12',
            'cost_price' => 50000,
            'selling_price' => 60000,
            'quantity' => 10,
        ]);

        // Sale
        Sale::create([
            'business_id' => $business->id,
            'product_id' => $product->id,
            'quantity' => 1,
            'total_amount' => 60000,
            'profit' => 10000,
            'date' => today(),
        ]);

        // Repair
        Repair::create([
            'business_id' => $business->id,
            'customer_name' => 'John Doe',
            'phone' => '9812345678',
            'model' => 'Samsung A50',
            'problem' => 'repair',
            'charge' => 500,
            'status' => 'done',
            'date' => today(),
        ]);

        // Second-hand
        SecondHand::create([
            'business_id' => $business->id,
            'customer_name' => 'Jane Doe',
            'phone' => '9823456789',
            'mobile_model' => 'iPhone 11',
            'imei' => '123456789012345',
            'buy_price' => 30000,
            'condition' => 'Good',
            'date' => today(),
        ]);

        // Unlock Order
        UnlockOrder::create([
            'business_id' => $business->id,
            'customer_name' => 'Bob Smith',
            'phone' => '9834567890',
            'device_model' => 'iPhone 13',
            'imei' => '987654321098765',
            'service_type' => 'icloud',
            'note' => 'Urgent unlock',
            'status' => 'pending',
        ]);

        // Payment
        BusinessPayment::create([
            'business_id' => $business->id,
            'amount' => 1000,
            'payment_method' => 'esewa',
            'status' => 'pending',
            'date' => today(),
        ]);
    }
}