<?php

namespace App\Models;

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

class Expense extends Model
{
    use HasFactory, Auditable;

    protected $fillable = [
        'user_id', 'expense_type_id', 'segment_id', 'date', 'amount',
        'due', 'payment_status', 'description', 'payment_method', 'bank_account_id',
        'digital_payment_id', 'reference'
    ];

    protected $casts = [
        'date' => 'date',
        'amount' => 'decimal:2',
        'due' => 'decimal:2'
    ];

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

    public function expenseType()
    {
        return $this->belongsTo(ExpenseType::class);
    }

    public function segment()
    {
        return $this->belongsTo(Segment::class);
    }

    public function bankAccount()
    {
        return $this->belongsTo(BankAccount::class);
    }

    public function digitalPayment()
    {
        return $this->belongsTo(DigitalPayment::class);
    }
}
