<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ExpenseSetting extends Model
{
    protected $fillable = [
        'require_approval',
        'approval_threshold',
        'default_categories',
        'notes',
    ];

    protected function casts(): array
    {
        return [
            'require_approval' => 'boolean',
            'approval_threshold' => 'decimal:2',
            'default_categories' => 'array',
        ];
    }

    public static function getSettings(): self
    {
        return static::firstOrCreate([], [
            'require_approval' => false,
            'approval_threshold' => null,
            'default_categories' => [],
        ]);
    }
}
