Skip to content

Commit

Permalink
fix the getEditableEntityFields() method and route definition
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Mar 15, 2024
1 parent 7a99c4d commit fd2f1ea
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion server/src/Http/Controllers/Api/v1/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion server/src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit fd2f1ea

Please sign in to comment.