<?php

namespace Database\Seeders;

use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Faker\Generator as Faker;
Use App\Models\{Product, Product_category};
use Illuminate\Database\Eloquent\Factories\Factory;
class productSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        // Aquí puedes agregar la lógica para crear productos de ejemplo
        for($i=1; $i<=2; $i++){
                $idCompanyNew = Product_category::where('category_name', 'Alimento')->first()->id;
                $faker = \Faker\Factory::create('es_VE');
                $price = $faker->randomNumber(5, true);
                if ($price < 1.5 || $price > 5) {
                    $price = $faker->randomFloat(2, 1.5, 5);
                }
                $salePrice = $price + ($price * 0.2);  
                Product::create([
                    'product_name' => $faker->randomElement(['Pepsi', 'Coca Cola', 'Galletas', 'Barritas de Proteina','Gatorade','Agua mineral']),
                    'description' => $faker->words(10, true),
                    'sale_price' => round($salePrice, 2),
                    'purchase_price' => round($price, 2),
                    'current_stock' => $faker->numberBetween(0, 100),
                    'category_id' => $idCompanyNew,
                    'minimum_stock' => $faker->numberBetween(0, 20),
                    'barcode' => $faker->unique()->ean13()
            ]);
        }
    }
}
