diff --git a/routes/admin_work_flow.php b/routes/admin_work_flow.php index 6266096b..1970d2cd 100644 --- a/routes/admin_work_flow.php +++ b/routes/admin_work_flow.php @@ -138,4 +138,33 @@ Route::group(['prefix' => 'admin-work-flow', 'as' => 'admin_work_flow.', 'namesp return jsonResponse($remark, 'Remark created successfully', 201); })->name('create_1688_login_issue_remark'); + + Route::post('/create_approve_issue_remark', function (Request $request) { + $validator = Validator::make($request->all(), [ + 'booking_id' => 'required', + 'remark' => 'required', + 'user_id' => 'required', + ]); + + if ($validator->fails()) { + throw new RequestValidationException($validator->messages()->first()); + } + + $booking = Booking::find($request->booking_id); + + if (!$booking) { + return jsonResponse(null, 'Booking not found', 404); + } + + $remark = new Remark([ + 'commenter_id' => $request->user_id, + 'content' => $request->remark, + 'owner_type' => get_class($booking), + 'owner_id' => $booking->id, + ]); + + $remark->save(); + + return jsonResponse($remark, 'Remark created successfully', 201); + })->name('create_approve_issue_remark'); });