Files
finance_app/app/Models/Expense.php
henry yo 85972f950c feat: 前端分離+功能api化
1. 新增資產管理CRUD、googleOAuth登入
2. 更改原記帳controller
2026-06-25 14:19:07 +08:00

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);
}
}