- Heavy rework on search request handling of entities

This commit is contained in:
Dev committed 2025-12-02 00:15:54 +00:00
1 parent a9b9c2cce9
commit 11e436236c
8 files changed
+290 -167

No files matched your search

+99
View File
@@ -9,9 +9,108 @@ class SearchRequest implements SearchRequestInterface
{
use SearchRequestPaginationTrait, SearchRequestFromRequestTrait;
protected array $wheres = [];
protected array $wheresConditions = [];
protected array $wheresOperators = [];
protected array $likes = [];
protected array $likesOperators = [];
protected array $likesConditions = [];
protected array $groups = [];
protected array $orders = [];
/* [[ Boilerplates which are ready to be copied */
public function wheres() : iterable
{
return array_filter($this->wheres + [
], fn($i) => ! is_null($i) ) + [ ];
}
public function wheresConditions() : iterable
{
return array_filter($this->wheresConditions + [
], fn($i) => ! is_null($i) ) + [ ];
}
public function wheresOperators() : iterable
{
return array_filter($this->wheresOperators + [
], fn($i) => ! is_null($i) ) + [ ];
}
public function likes(): iterable
{
return array_filter($this->likes + [
], fn($i) => ! is_null($i) ) + [];
}
public function likesConditions() : iterable
{
return array_filter($this->likesConditions + [
], fn($i) => ! is_null($i) ) + [ ];
}
public function likesOperators() : iterable
{
return array_filter($this->likesOperators + [
], fn($i) => ! is_null($i) ) + [ ];
}
public function groups(): iterable
{
return array_filter($this->groups + [
], fn($e) => ! is_null($e) && $e !== "" );
}
public function orders(): iterable
{
return array_filter($this->orders + [
], fn($e) => ! is_null($e) && $e !== "" );
}
/* ]] */
public function filter(Repository $repository) : Repository
{
return $repository;
}
public function applyCount(Repository\RepositoryInterface $repository): SearchRequestInterface
{
$this->count = $this->fromParsedParameters($repository)
->filter($repository)
->wheres($this->wheres(), $this->wheresOperators(), $this->wheresConditions())
->likes($this->likes(), $this->likesConditions())
->groups($this->groups())
->count();
return $this;
}
public function apply(Repository\RepositoryInterface $repository): SearchRequestInterface
{
$this->fromParsedParameters($repository)
->filter($repository)
->wheres($this->wheres(), $this->wheresOperators(), $this->wheresConditions())
->likes($this->likes(), $this->likesConditions())
->orders($this->orders())
->groups($this->groups())
->offset($this->offset())
->limit($this->limit());
return $this;
}
}