add useFilters method in RepositoryQuery to handle array filtering
This commit is contained in:
parent
71e541b13e
commit
99a2cc87d3
|
@ -94,4 +94,29 @@ abstract class RepositoryQuery
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function filterHandler(string $name, $value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function useFilters(array $filters)
|
||||||
|
{
|
||||||
|
foreach ($filters as $name => $value) {
|
||||||
|
if (null === $value) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_int($value) || is_bool($value)) {
|
||||||
|
$this->andWhere('.'.$name.' = :'.$name);
|
||||||
|
$this->setParameter(':'.$name, $value);
|
||||||
|
} elseif (is_string($value)) {
|
||||||
|
$this->andWhere('.'.$name.' LIKE :'.$name);
|
||||||
|
$this->setParameter(':'.$name, '%'.$value.'%');
|
||||||
|
} else {
|
||||||
|
$this->filterHandler($name, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue