<?php

namespace Database\Seeders;

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

class UnitSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $units = [
            ['name' => '個', 'code' => 'pc'],
            ['name' => '箱', 'code' => 'box'],
            ['name' => '瓶', 'code' => 'btl'],
            ['name' => '包', 'code' => 'pkg'],
            ['name' => '公斤', 'code' => 'kg'],
            ['name' => '公克', 'code' => 'g'],
            ['name' => '公升', 'code' => 'l'],
            ['name' => '毫升', 'code' => 'ml'],
            ['name' => '籃', 'code' => 'bsk'],
            ['name' => '桶', 'code' => 'bucket'],
            ['name' => '罐', 'code' => 'can'],
        ];

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