mirror of
https://github.com/henry4682/finance_app.git
synced 2026-07-16 00:10:00 +00:00
buid new app
This commit is contained in:
42
app/Models/Expense.php
Normal file
42
app/Models/Expense.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user