<?php

namespace Database\Seeders;

use App\Models\ExpenseCategory;
use App\Support\ExpenseCategoryLabels;
use Illuminate\Database\Seeder;

class ExpenseCategorySeeder extends Seeder
{
    /**
     * @var list<array{slug: string, name: string}>
     */
    private const DEFAULT_CATEGORIES = [
        ['slug' => ExpenseCategoryLabels::RENT, 'name' => 'Rent'],
        ['slug' => ExpenseCategoryLabels::FUEL, 'name' => 'Fuel'],
        ['slug' => ExpenseCategoryLabels::OIL, 'name' => 'Oil'],
        ['slug' => ExpenseCategoryLabels::ELECTRICITY, 'name' => 'Electricity'],
        ['slug' => ExpenseCategoryLabels::INTERNET, 'name' => 'Internet'],
        ['slug' => ExpenseCategoryLabels::WATER, 'name' => 'Water'],
        ['slug' => ExpenseCategoryLabels::OFFICE_SUPPLIES, 'name' => 'Office supplies'],
        ['slug' => ExpenseCategoryLabels::STAFF_MEALS, 'name' => 'Staff meals'],
        ['slug' => ExpenseCategoryLabels::TRANSPORT, 'name' => 'Transport'],
        ['slug' => ExpenseCategoryLabels::REPAIRS, 'name' => 'Repairs'],
        ['slug' => ExpenseCategoryLabels::CLEANING, 'name' => 'Cleaning'],
        ['slug' => ExpenseCategoryLabels::MISCELLANEOUS, 'name' => 'Miscellaneous'],
    ];

    public function run(): void
    {
        foreach (self::DEFAULT_CATEGORIES as $category) {
            ExpenseCategory::query()->updateOrCreate(
                ['slug' => $category['slug']],
                [
                    'name' => $category['name'],
                    'description' => null,
                    'is_active' => true,
                ],
            );
        }
    }
}
