<?php

namespace App\Models;

use App\Models\Traits\Filterable;
use App\Models\Traits\SelectOptions;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Balance extends Model
{
  use HasFactory, Filterable, SelectOptions;

  protected $fillable = [
    'company_id',
    'code',
    'user_id',
    'department_id',
    'debit_amount',
    'credit_amount',
    'year',
    'month',
  ];

  public function company()
  {
    return $this->belongsTo(Company::class, 'company_id');
  }

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

  public function department()
  {
    return $this->belongsTo(Department::class, 'department_id');
  }

  public function budgets()
  {
    return $this->hasMany(Budget::class, 'balance_id');
  }
}
