<?php

namespace Database\Seeders;

use App\Models\User;
use App\Models\Product;
use App\Models\Shop;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     */
    public function run(): void
    {
        // Create Admin
        User::create([
            'name' => 'Ravi Admin',
            'email' => 'admin@distroflow.com',
            'password' => Hash::make('password'),
            'role' => 'admin',
        ]);

        // Create Distributor
        User::create([
            'name' => 'Kumar Dist',
            'email' => 'dist@distroflow.com',
            'password' => Hash::make('password'),
            'role' => 'distributor',
        ]);

        // Create some Products
        Product::create([
            'name' => 'Premium Tea 250g',
            'sku' => 'TEA-PRM-250',
            'category' => 'Grocery',
            'buying_price' => 120,
            'selling_price' => 150,
            'min_price' => 145,
            'stock' => 100,
        ]);

        Product::create([
            'name' => 'Coconut Oil 1L',
            'sku' => 'OIL-COC-1L',
            'category' => 'Grocery',
            'buying_price' => 450,
            'selling_price' => 520,
            'min_price' => 510,
            'stock' => 50,
        ]);

        Product::create([
            'name' => 'Marie Biscuits 100g',
            'sku' => 'BIS-MAR-100',
            'category' => 'Snacks',
            'buying_price' => 45,
            'selling_price' => 60,
            'min_price' => 58,
            'stock' => 8, // Low stock
        ]);

        // Create some Shops
        Shop::create([
            'name' => 'City Supermarket',
            'owner' => 'Mr. Silva',
            'phone' => '0771234567',
            'city' => 'Colombo',
            'address' => 'No 45, Main Street, Colombo',
            'due_balance' => 1500.00,
        ]);

        Shop::create([
            'name' => 'Lanka Stores',
            'owner' => 'Mrs. Perera',
            'phone' => '0719876543',
            'city' => 'Kandy',
            'address' => '12/A, Lake Road, Kandy',
            'due_balance' => 0.00,
        ]);
    }
}
