Endpoint fix to view a customer's unit listing.
This commit is contained in:
parent
d1e3574501
commit
c4c177f967
@ -10,5 +10,5 @@ interface ContractInterface
|
|||||||
public function update(array $params, $id);
|
public function update(array $params, $id);
|
||||||
public function destroy($id);
|
public function destroy($id);
|
||||||
public function withRelationsByAll($relations);
|
public function withRelationsByAll($relations);
|
||||||
public function search($params, $distinct = false);
|
public function search($param);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,7 @@ trait MethodsTrait
|
|||||||
return $this->model->with($relations)->get();
|
return $this->model->with($relations)->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function search($params, $distinct = false)
|
public function search($params)
|
||||||
{
|
{
|
||||||
$filter = static::getFilterBuilder($params);
|
$filter = static::getFilterBuilder($params);
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ trait MethodsTrait
|
|||||||
|
|
||||||
$response = $filter->applyFilter($query);
|
$response = $filter->applyFilter($query);
|
||||||
|
|
||||||
if (isset($distinct)){
|
if ($filter->isDistinct()){
|
||||||
$response = $response->distinct();
|
$response = $response->distinct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,8 @@ class FilterQueryBuilder extends EntityJson implements IFilterBuilder
|
|||||||
|
|
||||||
protected array $fields = [];
|
protected array $fields = [];
|
||||||
|
|
||||||
|
protected bool $distinct = false;
|
||||||
|
|
||||||
|
|
||||||
public function applyFilter(Builder $builder): Builder
|
public function applyFilter(Builder $builder): Builder
|
||||||
{
|
{
|
||||||
@ -123,4 +125,24 @@ class FilterQueryBuilder extends EntityJson implements IFilterBuilder
|
|||||||
$this->offset = $offset;
|
$this->offset = $offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isDistinct(): bool
|
||||||
|
{
|
||||||
|
return $this->distinct;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $distinct
|
||||||
|
*/
|
||||||
|
public function setDistinct(bool $distinct): void
|
||||||
|
{
|
||||||
|
$this->distinct = $distinct;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user