<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

use App\Traits\HasAuditLog;
use App\Traits\ScopedByOwner;

class Expense extends Model
{
    use HasAuditLog, SoftDeletes, ScopedByOwner;
    protected $fillable = [
        'user_id',
        'description',
        'amount',
        'category',
        'reference',
        'expense_date'
    ];

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

    /**
     * Get the user that registered the expense.
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }
}
