<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Expense extends Model
{
    protected $fillable = [
        'user_id',
        'expense_category_id',
        'user_account_id',
        'amount',
        'posted_at',
        'date',
        'trx_no',
        'note',
        'proof_photo',
    ];

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

    public function category()
    {
        return $this->belongsTo(ExpenseCategory::class, 'expense_category_id');
    }

    public function account()
    {
        return $this->belongsTo(UserAccount::class, 'user_account_id');
    }

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