- Bugfixes done linked to SearchRequest and Searchable features.
- Fixed a bug introduced into PdoObject exception on latest commit. - Corrected the open() close() enclosure of query condition.
This commit is contained in:
1 parent
f98cb2ded0
commit
84da4dbb7b
9 files changed
+111
-20
No files matched your search
+52
-10
@@ -217,7 +217,24 @@ class Repository
|
||||
public function wheres(array $fieldValues, string $operator = Query\Where::OPERATOR_EQUAL) : self
|
||||
{
|
||||
foreach($fieldValues as $field => $value) {
|
||||
$this->where($field, $value, $operator);
|
||||
if ( is_array($value) ) {
|
||||
switch ($value[1]) {
|
||||
case Query\Where::CONDITION_AND:
|
||||
$this->where($field, $value[0], $operator);
|
||||
break;
|
||||
|
||||
case Query\Where::CONDITION_OR:
|
||||
$this->or($field, $value[0], $operator);
|
||||
break;
|
||||
|
||||
case Query\Where::CONDITION_NOT:
|
||||
$this->notWhere($field, $value[0], $operator);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->where($field, $value, $operator);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -287,23 +304,46 @@ class Repository
|
||||
|
||||
public function like($field, $value) : self
|
||||
{
|
||||
$this->queryBuilder->where($field, $value, Query\Where::OPERATOR_LIKE, Query\Where::CONDITION_AND);
|
||||
$this->where($field, $value, Query\Where::OPERATOR_LIKE);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function orLike($field, $value) : self
|
||||
{
|
||||
$this->or($field, $value, Query\Where::OPERATOR_LIKE);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function notLike($field, $value) : self
|
||||
{
|
||||
$this->queryBuilder->notWhere($field, $value, Query\Where::OPERATOR_LIKE, Query\Where::CONDITION_AND, true);
|
||||
$this->notWhere($field, $value, Query\Where::OPERATOR_LIKE);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function likes(array $fieldValues) : self
|
||||
public function likes(array $fieldValues, string $condition = Query\Where::CONDITION_AND) : self
|
||||
{
|
||||
foreach($fieldValues as $field => $value) {
|
||||
$this->like($field, $value);
|
||||
if ( is_array($value) ) {
|
||||
switch ($value[1]) {
|
||||
case Query\Where::CONDITION_AND:
|
||||
$this->like($field, $value[0]);
|
||||
break;
|
||||
|
||||
case Query\Where::CONDITION_OR:
|
||||
$this->orLike($field, $value[0]);
|
||||
break;
|
||||
|
||||
case Query\Where::CONDITION_NOT:
|
||||
$this->notLike($field, $value[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->like($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -394,14 +434,16 @@ class Repository
|
||||
|
||||
public function filterServerRequest(SearchRequest\SearchRequestInterface $searchRequest) : self
|
||||
{
|
||||
$searchRequest->count = (clone $this)->wheres($searchRequest->wheres())
|
||||
->likes($searchRequest->likes())
|
||||
$searchRequest->count = $searchRequest->filter( clone $this )
|
||||
->wheres($searchRequest->wheres(), Query\Where::OPERATOR_EQUAL, Query\Where::CONDITION_AND)
|
||||
->likes($searchRequest->likes(), Query\Where::CONDITION_OR)
|
||||
->orders($searchRequest->orders())
|
||||
->groups($searchRequest->groups())
|
||||
->count();
|
||||
|
||||
return $this->wheres($searchRequest->wheres())
|
||||
->likes($searchRequest->likes())
|
||||
return $searchRequest->filter($this)
|
||||
->wheres($searchRequest->wheres(), Query\Where::OPERATOR_EQUAL, Query\Where::CONDITION_AND)
|
||||
->likes($searchRequest->likes(), Query\Where::CONDITION_OR)
|
||||
->orders($searchRequest->orders())
|
||||
->groups($searchRequest->groups())
|
||||
->offset($searchRequest->offset())
|
||||
|
||||
Reference in new issue
Block a user