From fd2f1ea300db6079a78d0917fd3d06fac3406431 Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Fri, 15 Mar 2024 16:42:01 +0800 Subject: [PATCH] fix the `getEditableEntityFields()` method and route definition --- .../Controllers/Api/v1/OrderController.php | 18 +++++++++++++++++- server/src/routes.php | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/server/src/Http/Controllers/Api/v1/OrderController.php b/server/src/Http/Controllers/Api/v1/OrderController.php index e31cb754..77a8fec0 100644 --- a/server/src/Http/Controllers/Api/v1/OrderController.php +++ b/server/src/Http/Controllers/Api/v1/OrderController.php @@ -1364,7 +1364,23 @@ public function capturePhoto(Request $request, string $id, ?string $subjectId = return new ProofResource($proof); } - public function getEntityEditableFields(string $id, Request $request) + /** + * Retrieves editable fields for a specific order entity based on its configuration. + * + * This function looks up an order by its ID and retrieves configurable editable fields + * associated with it, as defined in the settings. If the order is not found, it returns + * a 404 response with an error message. Otherwise, it returns the editable fields for + * the order entity. + * + * @param string $id the unique identifier of the order + * @param Request $request the incoming request instance + * + * @return \Illuminate\Http\JsonResponse returns a JSON response containing either an error message + * or the editable fields for the order entity + * + * @throws \Illuminate\Database\Eloquent\ModelNotFoundException thrown if the order with the given ID cannot be found + */ + public function getEditableEntityFields(string $id, Request $request) { try { $order = Order::findRecordOrFail($id); diff --git a/server/src/routes.php b/server/src/routes.php index eb350f51..28f950be 100644 --- a/server/src/routes.php +++ b/server/src/routes.php @@ -84,7 +84,7 @@ function ($router) { $router->post('{id}/capture-photo/{subjectId?}', 'OrderController@capturePhoto'); $router->put('{id}', 'OrderController@update'); $router->delete('{id}', 'OrderController@delete'); - $router->delete('{id}', 'OrderController@getEntityEditableFields'); + $router->get('{id}/editable-entity-fields', 'OrderController@getEditableEntityFields'); }); // entities routes $router->group(['prefix' => 'entities'], function () use ($router) {