55 lines
1.3 KiB
PHP
55 lines
1.3 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 Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Modules\Auth\Entities\User;
|
|
use Modules\Investment\Enums\InvestmentAccountStatus;
|
|
|
|
class InvestmentAccount extends Model
|
|
{
|
|
use HasUuids;
|
|
|
|
protected $table = 'investment_accounts';
|
|
|
|
protected $fillable = [
|
|
'user_id',
|
|
'investment_type_id',
|
|
'current_balance',
|
|
'pending_balance',
|
|
'status',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'status' => InvestmentAccountStatus::class,
|
|
'current_balance' => 'decimal:2',
|
|
'pending_balance' => 'decimal:2',
|
|
];
|
|
}
|
|
|
|
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 investments(): HasMany
|
|
{
|
|
return $this->hasMany(Investment::class, 'investment_account_id');
|
|
}
|
|
|
|
public function ledgerEntries(): HasMany
|
|
{
|
|
return $this->hasMany(InvestmentLedger::class, 'investment_account_id');
|
|
}
|
|
}
|