<?php

namespace Database\Seeders;

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

class UnitSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $defaults = [
            ['name' => 'Kilogram', 'alias' => 'kg'],
            ['name' => 'Gram', 'alias' => 'g'],
            ['name' => 'Sak', 'alias' => 'sak'],
            ['name' => 'Karung', 'alias' => 'karung'],
            ['name' => 'Liter', 'alias' => 'ltr'],
            ['name' => 'Butir', 'alias' => 'butir'],
        ];

        foreach ($defaults as $data) {
            Unit::firstOrCreate(
                ['alias' => $data['alias']],
                ['name' => $data['name']]
            );
        }
    }
}
