<?php

namespace Database\Seeders;

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

class MeasurementUnitSeeder extends Seeder
{
    public function run(): void
    {
        foreach (config('units', []) as $unit) {
            MeasurementUnit::updateOrCreate(
                ['code' => $unit['code']],
                [
                    'name' => $unit['name'],
                    'is_gst' => (bool) ($unit['gst'] ?? false),
                ]
            );
        }
    }
}
