56 lines
1.2 KiB
PHP
56 lines
1.2 KiB
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\HasMany;
|
|
|
|
class Transaction extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $guarded = [];
|
|
|
|
/**
|
|
* Get the expense that owns the Transaction
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function expense(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Expense::class);
|
|
}
|
|
|
|
/**
|
|
* Get the sale that owns the Transaction
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function sale(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Sale::class);
|
|
}
|
|
|
|
/**
|
|
* Get the account that owns the Transaction
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function account(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Account::class);
|
|
}
|
|
|
|
/**
|
|
* Get the ledgers associated with the Transaction
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
|
*/
|
|
public function ledgers(): HasMany
|
|
{
|
|
return $this->hasMany(Ledger::class);
|
|
}
|
|
}
|