<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\Unit;

class UnitSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $units = [
            [
                'name' => 'Kilogram',
                'abbreviation' => 'kg',
                'description' => 'Kilogram - standard unit of mass',
                'status' => 'active',
                'is_default' => true,
                'restaurant_id' => null,
            ],
            [
                'name' => 'Gram',
                'abbreviation' => 'g',
                'description' => 'Gram - unit of mass',
                'status' => 'active',
                'is_default' => true,
                'restaurant_id' => null,
            ],
            [
                'name' => 'Piece',
                'abbreviation' => 'pcs',
                'description' => 'Piece - individual item count',
                'status' => 'active',
                'is_default' => true,
                'restaurant_id' => null,
            ],
            [
                'name' => 'Box',
                'abbreviation' => 'box',
                'description' => 'Box - packaged unit',
                'status' => 'active',
                'is_default' => true,
                'restaurant_id' => null,
            ],
            [
                'name' => 'Liter',
                'abbreviation' => 'liter',
                'description' => 'Liter - unit of volume',
                'status' => 'active',
                'is_default' => true,
                'restaurant_id' => null,
            ],
            [
                'name' => 'Pack',
                'abbreviation' => 'pack',
                'description' => 'Pack - packaged unit',
                'status' => 'active',
                'is_default' => true,
                'restaurant_id' => null,
            ],
            [
                'name' => 'Bottle',
                'abbreviation' => 'bottle',
                'description' => 'Bottle - container unit',
                'status' => 'active',
                'is_default' => true,
                'restaurant_id' => null,
            ],
        ];

        foreach ($units as $unit) {
            Unit::updateOrCreate(
                ['name' => $unit['name'], 'is_default' => true],
                $unit
            );
        }
    }
}

