<?php

namespace Database\Seeders;

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

class UnitSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $units = [
            ['name' => '個', 'code' => 'PCE'], // Piece
            ['name' => '箱', 'code' => 'BX'],  // Box
            ['name' => '瓶', 'code' => 'BO'],  // Bottle
            ['name' => '包', 'code' => 'PK'],  // Package
            ['name' => '公斤', 'code' => 'KGM'], // Kilogram
            ['name' => '公克', 'code' => 'GRM'], // Gram
            ['name' => '公升', 'code' => 'LTR'], // Litre
            ['name' => '毫升', 'code' => 'MLT'], // Millilitre
            ['name' => '籃', 'code' => 'BK'],  // Basket
            ['name' => '桶', 'code' => 'BJ'],  // Bucket
            ['name' => '罐', 'code' => 'CA'],  // Can
        ];

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