make app database

This commit is contained in:
Meghdad
2026-07-22 15:38:08 +03:30
parent 626a1e5373
commit 36b6bc544d
25 changed files with 1059 additions and 9 deletions

73
app/Models/Loan.php Normal file
View File

@@ -0,0 +1,73 @@
<?php
namespace App\Models;
use App\Domain\Loan\Enums\LoanStatus;
use Database\Factories\LoanFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
#[Fillable([
'public_id',
'customer_id',
'loan_type_id',
'workflow_configuration_id',
'current_workflow_configuration_step_id',
'amount',
'phone',
'monthly_income',
'credit_score',
'has_guarantor',
'status',
])]
class Loan extends Model
{
/** @use HasFactory<LoanFactory> */
use HasFactory;
protected $attributes = [
'status' => LoanStatus::Submitted->value,
];
public function getRouteKeyName(): string
{
return 'public_id';
}
public function loanType(): BelongsTo
{
return $this->belongsTo(LoanType::class);
}
public function workflowConfiguration(): BelongsTo
{
return $this->belongsTo(WorkflowConfiguration::class);
}
public function currentStep(): BelongsTo
{
return $this->belongsTo(WorkflowConfigurationStep::class, 'current_workflow_configuration_step_id');
}
public function histories(): HasMany
{
return $this->hasMany(LoanHistory::class);
}
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'amount' => 'integer',
'monthly_income' => 'integer',
'credit_score' => 'integer',
'has_guarantor' => 'boolean',
'status' => LoanStatus::class,
];
}
}