<?php

namespace Database\Seeders;

use App\Models\Bottle;
use App\Models\Outlet;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;

class BottleSeeder extends Seeder
{
    public function run(): void
    {
        $bottles = [
            ['name' => 'Botol Kaca 30ml Elegant', 'size' => 30, 'cost_price' => 3000],
            ['name' => 'Botol Kaca 50ml Premium', 'size' => 50, 'cost_price' => 5000],
            ['name' => 'Botol Kaca 100ml Classic', 'size' => 100, 'cost_price' => 10000],
            ['name' => 'Botol Plastik 30ml Travel', 'size' => 30, 'cost_price' => 3000],
            ['name' => 'Botol Aluminium 100ml Refill', 'size' => 100, 'cost_price' => 10000],
            ['name' => 'Botol Roll On 6ml Mini', 'size' => 6, 'cost_price' => 600],
            ['name' => 'Botol Spray 15ml Slim', 'size' => 15, 'cost_price' => 1500],
            ['name' => 'Botol Kaca 250ml Jumbo', 'size' => 250, 'cost_price' => 25000],
            ['name' => 'Botol Kristal 50ml Luxury', 'size' => 50, 'cost_price' => 5000],
            ['name' => 'Botol Refill 500ml Bulk', 'size' => 500, 'cost_price' => 50000],
        ];

        foreach ($bottles as $bottle) {
            $slug = Str::slug($bottle['name']);

            $bottle = Bottle::create([
                'name' => $bottle['name'],
                'slug' => $slug,
                'size' => $bottle['size'],
                'cost_price' => $bottle['cost_price'],
                'sale_price' => $bottle['cost_price'] * 2,
                'point_per_pcs' => round($bottle['cost_price'] / 100),
                'description' => fake()->sentence(10),
            ]);

            $bottle->outlets()->attach(Outlet::all()->pluck('id')->toArray());
        }
    }
}
