<?php

namespace App\Models;

use App\Traits\BelongsToOrganization;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ExpenseCategory extends Model
{
    use HasFactory, BelongsToOrganization;

    protected $fillable = ['name', 'color', 'description', 'is_active', 'organization_id'];

    protected function casts(): array
    {
        return ['is_active' => 'boolean'];
    }

    public function expenses()
    {
        return $this->hasMany(Expense::class, 'category', 'name');
    }
}
