58 lines
1.4 KiB
PHP
58 lines
1.4 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\SalaryContributionStatus;
|
|
|
|
class SalaryContribution extends Model
|
|
{
|
|
use HasUuids;
|
|
|
|
protected $table = 'salary_contributions';
|
|
|
|
protected $fillable = [
|
|
'user_id',
|
|
'investment_type_id',
|
|
'monthly_amount',
|
|
'start_date',
|
|
'end_date',
|
|
'status',
|
|
'created_by',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'monthly_amount' => 'decimal:2',
|
|
'start_date' => 'date',
|
|
'end_date' => 'date',
|
|
'status' => SalaryContributionStatus::class,
|
|
];
|
|
}
|
|
|
|
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');
|
|
}
|
|
|
|
public function batchDetails(): HasMany
|
|
{
|
|
return $this->hasMany(SalaryDeductionBatchDetail::class, 'salary_contribution_id');
|
|
}
|
|
}
|