refactor: simplify API controller resource responses

This commit is contained in:
Meghdad committed 2026-07-23 00:20:06 +03:30
1 parent d5c39a2bd7
commit 7e3b6e2380
2 files changed
+8 -8

No files matched your search

@@ -16,24 +16,24 @@ use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
class LoanController extends Controller
{
public function store(StoreLoanRequest $request, CreateLoanAction $createLoan): JsonResponse
public function store(StoreLoanRequest $request, CreateLoanAction $createLoan)
{
$loan = $createLoan->handle($request->validated());
return (new LoanProcessResource($loan))->response()->setStatusCode(201);
return LoanProcessResource::make($loan);
}
public function process(string $loanId, ProcessLoanAction $processLoan): JsonResponse
public function process(string $loanId, ProcessLoanAction $processLoan)
{
return (new LoanProcessResource($processLoan->handle($loanId)))->response();
return LoanProcessResource::make($processLoan->handle($loanId));
}
public function show(string $loanId, GetLoanAction $getLoan): JsonResponse
public function show(string $loanId, GetLoanAction $getLoan)
{
return (new LoanResource($getLoan->handle($loanId)))->response();
return LoanResource::make($getLoan->handle($loanId));
}
public function history(string $loanId, GetLoanHistoryAction $getLoanHistory): AnonymousResourceCollection
public function history(string $loanId, GetLoanHistoryAction $getLoanHistory)
{
return LoanHistoryResource::collection($getLoanHistory->handle($loanId));
}
@@ -6,7 +6,7 @@ use Illuminate\Http\JsonResponse;
class HealthCheckController extends Controller
{
public function __invoke(): JsonResponse
public function __invoke()
{
return response()->json(['status' => 'UP']);
}