1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sanderdekroon\Parlant\Builder; |
4
|
|
|
|
5
|
|
|
use Closure; |
6
|
|
|
use InvalidArgumentException; |
7
|
|
|
|
8
|
|
|
trait QueriesTaxonomies |
9
|
|
|
{ |
10
|
4 |
|
public function whereTaxonomy($taxonomy, $field = null, $operator = null, $value = null, $includeChildren = true, $relation = null, $level = 1) |
11
|
|
|
{ |
12
|
4 |
|
$clause = new WhereTaxonomyClause($this->getGrammar()); |
|
|
|
|
13
|
|
|
|
14
|
4 |
|
foreach ($clause->build($taxonomy, $field, $operator, $value, $includeChildren, $relation, $level) as $where) { |
15
|
4 |
|
$this->appendBinding('whereTaxonomies', $where); |
|
|
|
|
16
|
|
|
} |
17
|
|
|
|
18
|
4 |
|
$this->setBinding('whereTaxonomyRelation', $clause->getRelation() + ($this->getBinding('whereTaxonomyRelation') ?: [1 => 'AND'])); |
|
|
|
|
19
|
|
|
|
20
|
4 |
|
return $this; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Query the meta values (custom post fields) of posts and set the relation to OR |
25
|
|
|
* @param string $taxonomy The field name |
26
|
|
|
* @param string $operator |
27
|
|
|
* @param mixed $value |
28
|
|
|
* @param string $type The type comparison, for example NUMERIC or CHAR |
29
|
|
|
* @param integer $level The query level, currently unimplemented |
30
|
|
|
* @return $this |
31
|
|
|
*/ |
32
|
1 |
|
public function orWhereTaxonomy($taxonomy, $field = null, $operator = null, $value = null, $includeChildren = true, $level = 1) |
33
|
|
|
{ |
34
|
1 |
|
return $this->whereTaxonomy($taxonomy, $field, $operator, $value, $includeChildren, 'OR', $level); |
35
|
|
|
} |
36
|
|
|
} |
37
|
|
|
|