Files
MKM/app/Models/Expense.php
2024-08-15 20:11:21 +08:00

33 lines
687 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
class Expense extends Model
{
use HasFactory;
protected $guarded = [];
protected $casts = [
'happened_on' => 'date:Y-m-d',
];
/**
* Get all the transactions for the Sale
*/
public function transactions(): MorphToMany
{
return $this->morphToMany(Transaction::class, 'transactionable');
}
public function branch(): BelongsTo
{
return $this->belongsTo(Branch::class);
}
}