<?php

namespace App\Models;

use App\Models\Concerns\HasOwnerScope;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Budget extends Model
{
    use HasOwnerScope;

    protected $fillable = [
        'user_id',
        'external_id',
        'name',
        'category_id',
        'limit_amount',
        'spent_amount',
        'period',
        'icon',
    ];

    protected function casts(): array
    {
        return [
            'limit_amount' => 'float',
            'spent_amount' => 'float',
        ];
    }

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }
}
