<?php

namespace App\Models;

use App\Enums\BudgetStatus;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Budget extends Model
{
    protected $table = 'budgets';

    protected $fillable = [
        'project_id',
        'bedrag',
        'type',
        'periode',
        'status',
    ];

    protected function casts(): array
    {
        return [
            'status' => BudgetStatus::class,
            'bedrag' => 'decimal:2',
        ];
    }

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

    public function bestedingen(): HasMany
    {
        return $this->hasMany(Besteding::class);
    }
}
