<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\User;
use App\Models\Product;
use App\Models\Client;
use App\Models\Appointment;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;

class DatabaseSeeder extends Seeder
{
    public function run(): void
    {
        //Crear el Super Admin
        User::factory()->create([
            'name' => 'Jose Admin',
            'email' => 'admin@lauck.com',
            'password' => bcrypt('password'), // Cambiar en producción
            'role' => 'admin',
        ]);

        //Crear un Empleado de prueba
        User::factory()->create([
            'name' => 'Empleado Test',
            'email' => 'taller@lauck.com',
            'password' => bcrypt('password'),
            'role' => 'employee',
        ]);

        //Crear Productos
        Product::create([
            'name' => 'Cámara 29 Válvula Auto',
            'sku' => 'CAM-29-A',
            'price' => 5000,
            'cost' => 2500,
            'stock_quantity' => 20,
            'min_stock_alert' => 5,
            'type' => 'accessory'
        ]);
        
        Product::create([
            'name' => 'Venzo Loki Evo 29',
            'sku' => 'BIC-VEN-001',
            'price' => 450000,
            'cost' => 300000,
            'stock_quantity' => 2,
            'min_stock_alert' => 1,
            'type' => 'bike',
            'serial_number' => 'VZ998877'
        ]);

        // Generar 10 productos aleatorios más
        Product::factory(10)->create();

        // Clientes y Turnos
        $client = Client::create([
            'name' => 'Juan Perez',
            'phone' => '1122334455',
            'email' => 'juan@gmail.com'
        ]);

        Appointment::create([
            'client_id' => $client->id,
            'scheduled_at' => now()->addDays(1)->setHour(10)->setMinute(0),
            'bike_model' => 'Trek Marlin 5',
            'problem_description' => 'Service completo y ajuste de cambios',
            'status' => 'pending'
        ]);
    }
}
