mirror of
https://github.com/grocy/grocy.git
synced 2025-08-13 01:06:23 +00:00
Filtering of API-Results (#985)
* Add FilteredApiResponse * Use FilteredApiResponse for Generic-Entity-Search * Use FilteredApiResponse for Recipe-Fullfillment * Use FilteredApiResponse for GetUsers * Use FilteredApiResponse for current Tasks * Use FilteredApiResponse for ProductStockEntries & ProductStockLocations * Use FilteredApiResponse for current chores * Use FilteredApiResponse for batteries-current * Fix missing highlighting of "< X days" * Keep to use existing views Co-authored-by: Bernd Bestel <bernd@berrnd.de>
This commit is contained in:
committed by
GitHub
parent
60f3d900e8
commit
32a4f81f62
@@ -3,6 +3,7 @@
|
||||
namespace Grocy\Controllers;
|
||||
|
||||
use Grocy\Controllers\Users\User;
|
||||
use Slim\Exception\HttpBadRequestException;
|
||||
|
||||
class GenericEntityApiController extends BaseApiController
|
||||
{
|
||||
@@ -178,12 +179,13 @@ class GenericEntityApiController extends BaseApiController
|
||||
{
|
||||
try
|
||||
{
|
||||
return $this->ApiResponse($response, $this->getDatabase()->{$args['entity']}
|
||||
()->where('name LIKE ?', '%' . $args['searchString'] . '%'));
|
||||
return $this->FilteredApiResponse($response, $this->getDatabase()->{$args['entity']}
|
||||
()->where('name LIKE ?', '%' . $args['searchString'] . '%'), $request->getQueryParams());
|
||||
}
|
||||
catch (\PDOException $ex)
|
||||
{
|
||||
return $this->GenericErrorResponse($response, 'The given entity has no field "name"');
|
||||
throw new HttpBadRequestException($request, $ex->getMessage(), $ex);
|
||||
//return $this->GenericErrorResponse($response, 'The given entity has no field "name"', $ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user