mirror of
https://github.com/grocy/grocy.git
synced 2025-08-13 01:06:23 +00:00
Added an API endpoint to search for objects by name (closes #337)
This commit is contained in:
@@ -113,6 +113,25 @@ class GenericEntityApiController extends BaseApiController
|
||||
}
|
||||
}
|
||||
|
||||
public function SearchObjects(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
if ($this->IsValidEntity($args['entity']) && !$this->IsEntityWithPreventedListing($args['entity']))
|
||||
{
|
||||
try
|
||||
{
|
||||
return $this->ApiResponse($this->Database->{$args['entity']}()->where('name LIKE ?', '%' . $args['searchString'] . '%'));
|
||||
}
|
||||
catch (\PDOException $ex)
|
||||
{
|
||||
return $this->GenericErrorResponse($response, 'The given entity has no field "name"');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->GenericErrorResponse($response, 'Entity does not exist or is not exposed');
|
||||
}
|
||||
}
|
||||
|
||||
public function GetUserfields(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
try
|
||||
|
Reference in New Issue
Block a user