<?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' => 'Piece',
                'abbreviation' => 'pcs',
                'description' => 'Single individual item.',
                'is_active' => true,
            ],
            [
                'name' => 'Box',
                'abbreviation' => 'box',
                'description' => 'Boxed package.',
                'is_active' => true,
            ],
            [
                'name' => 'Pack',
                'abbreviation' => 'pack',
                'description' => 'Pack of items.',
                'is_active' => true,
            ],
            [
                'name' => 'Set',
                'abbreviation' => 'set',
                'description' => 'Combined set of items.',
                'is_active' => true,
            ],
            [
                'name' => 'Meter',
                'abbreviation' => 'm',
                'description' => 'Length measurement.',
                'is_active' => true,
            ]
        ];

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