where('public_id', $loanId) ->lockForUpdate() ->first(); if ($loan === null) { throw new LoanNotFoundException("Loan {$loanId} was not found."); } $loan->load([ 'loanType', 'workflowConfiguration.steps.stageDefinition', 'histories', 'currentStep.stageDefinition', ]); $processedLoan = $this->workflowEngine->process($loan); return $processedLoan->load(['loanType', 'currentStep.stageDefinition']); }, 3); } }