feat: implement BankFlow loan workflow API endpoints
This commit is contained in:
1 parent
56a52be180
commit
7824e8f015
43 files changed
+1403
-10
No files matched your search
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Loan;
|
||||
|
||||
use App\Domain\Loan\Exceptions\LoanNotFoundException;
|
||||
use App\Models\Loan;
|
||||
use App\Models\LoanHistory;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class GetLoanHistoryAction
|
||||
{
|
||||
/**
|
||||
* @return Collection<int, LoanHistory>
|
||||
*/
|
||||
public function handle(string $loanId): Collection
|
||||
{
|
||||
$loan = Loan::query()
|
||||
->select(['id', 'public_id'])
|
||||
->where('public_id', $loanId)
|
||||
->first();
|
||||
|
||||
if ($loan === null) {
|
||||
throw new LoanNotFoundException("Loan {$loanId} was not found.");
|
||||
}
|
||||
|
||||
return $loan->histories()
|
||||
->orderBy('executed_at')
|
||||
->orderBy('id')
|
||||
->get();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user