mirror of
https://github.com/henry4682/finance_app.git
synced 2026-07-16 08:20:00 +00:00
48 lines
805 B
PHP
48 lines
805 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Expense extends Model
|
|
{
|
|
protected $fillable = [
|
|
'user_id',
|
|
'amount',
|
|
'category_id',
|
|
'item_name',
|
|
'date',
|
|
'note',
|
|
'seller_name',
|
|
'account_id',
|
|
'is_amortized',
|
|
'period_start',
|
|
'period_end',
|
|
];
|
|
|
|
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');
|
|
}
|
|
|
|
public function account()
|
|
{
|
|
return $this->belongsTo(Account::class);
|
|
}
|
|
}
|