Files
finance_app/app/Models/Expense.php
2026-03-09 01:00:49 +08:00

43 lines
760 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Expense extends Model
{
protected $fillable = [
'user_id',
'category_id',
'subcategory_id',
'type',
'amount',
'note',
'date',
'invoice_number',
'seller_name',
'item_name',
'external_id',
];
protected $casts = [
'date' => 'date:Y-m-d',
'amount' => 'decimal:2',
];
public function user()
{
return $this->belongsTo(User::class);
}
public function category()
{
return $this->belongsTo(Category::class);
}
public function subcategory()
{
return $this->belongsTo(Category::class, 'subcategory_id');
}
}