Files
mykopkb-be/Modules/Investment/Entities/InvestmentLedger.php
T

68 lines
1.6 KiB
PHP

<?php
namespace Modules\Investment\Entities;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Modules\Auth\Entities\User;
use Modules\Investment\Enums\InvestmentLedgerTransactionType;
class InvestmentLedger extends Model
{
use HasUuids;
public $timestamps = false;
protected $table = 'investment_ledger';
protected $fillable = [
'investment_id',
'investment_account_id',
'user_id',
'investment_type_id',
'transaction_type',
'credit',
'debit',
'balance_after',
'created_by',
'created_at',
];
protected function casts(): array
{
return [
'transaction_type' => InvestmentLedgerTransactionType::class,
'credit' => 'decimal:2',
'debit' => 'decimal:2',
'balance_after' => 'decimal:2',
'created_at' => 'datetime',
];
}
public function investment(): BelongsTo
{
return $this->belongsTo(Investment::class, 'investment_id');
}
public function account(): BelongsTo
{
return $this->belongsTo(InvestmentAccount::class, 'investment_account_id');
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'user_id');
}
public function investmentType(): BelongsTo
{
return $this->belongsTo(InvestmentType::class, 'investment_type_id');
}
public function createdBy(): BelongsTo
{
return $this->belongsTo(User::class, 'created_by');
}
}