From 0a4980077ed2762ac6707d99db89964f7e2d9d28 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Tue, 15 Oct 2024 02:30:52 +0800 Subject: [PATCH] Laravel Vapor - Fix an error in code that causes deployment fail --- routes/admin_work_flow.php | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/routes/admin_work_flow.php b/routes/admin_work_flow.php index f7767523..5272276f 100644 --- a/routes/admin_work_flow.php +++ b/routes/admin_work_flow.php @@ -16,18 +16,30 @@ use Illuminate\Http\JsonResponse; Route::group(['prefix' => 'admin-work-flow', 'as' => 'admin_work_flow.', 'namespace' => 'AdminWorkFlow'], function () { // Generalized JSON response function - function jsonResponse($data = null, $message = null, $status = 200) - { - $response = ['message' => $message]; + // function jsonResponse($data = null, $message = null, $status = 200) + // { + // $response = ['message' => $message]; - if ($data !== null) { - $response['data'] = $data; + // if ($data !== null) { + // $response['data'] = $data; + // } + + // return response()->json($response, $status); + // } + + if (!function_exists('jsonResponse')) { + function jsonResponse($data = null, $message = null, $status = 200) + { + $response = ['message' => $message]; + + if ($data !== null) { + $response['data'] = $data; + } + + return response()->json($response, $status); } - - return response()->json($response, $status); } - Route::get('/fetch-oldest-order', function () { $booking = Booking::where('service_id', 4) ->where('status', ApprovalStatus::APPROVED) @@ -147,9 +159,9 @@ Route::group(['prefix' => 'admin-work-flow', 'as' => 'admin_work_flow.', 'namesp if ($validator->fails()) { throw new RequestValidationException($validator->messages()->first()); } - + $booking = Booking::find($request->booking_id); - + if (!$booking) { return jsonResponse(null, 'Booking not found', 404);