API: allow delete location by id (#14334)

* API: allow delete location by id

Otherwise impossible to delete location "".

* docs/API: location can be name or id for edit and delete
This commit is contained in:
bp0
2022-09-13 09:03:55 -05:00
committed by GitHub
parent 9cff8acb29
commit 384e0449c1
2 changed files with 5 additions and 5 deletions

View File

@@ -65,9 +65,9 @@ Output:
Deletes an existing location
Route: `/api/v0/locations/location`
Route: `/api/v0/locations/:location`
- location: name of the location to delete
- location: name or id of the location to delete
Example:
@@ -89,9 +89,9 @@ Output:
Edits a location
Route: `/api/v0/locations/location`
Route: `/api/v0/locations/:location`
- location: name of the location to edit
- location: name or id of the location to edit
Input:

View File

@@ -2855,7 +2855,7 @@ function del_location(Illuminate\Http\Request $request)
if (empty($location)) {
return api_error(400, 'No location has been provided to delete');
}
$location_id = get_location_id_by_name($location);
$location_id = ctype_digit($location) ? $location : get_location_id_by_name($location);
if (empty($location_id)) {
return api_error(400, "Failed to delete $location (Does not exists)");
}