1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Umbrellio\Postgres\Schema\Builders; |
6
|
|
|
|
7
|
|
|
use Illuminate\Support\Fluent; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @see Fluent |
11
|
|
|
*/ |
12
|
|
|
trait WhereBuilderTrait |
13
|
|
|
{ |
14
|
|
|
protected $attributes = []; |
15
|
|
|
|
16
|
2 |
|
public function whereRaw(string $sql, array $bindings = [], string $boolean = 'and'): self |
17
|
|
|
{ |
18
|
2 |
|
return $this->compileWhere('Raw', $boolean, compact('sql', 'bindings')); |
19
|
|
|
} |
20
|
|
|
|
21
|
2 |
|
public function where(string $column, string $operator, string $value, string $boolean = 'and'): self |
22
|
|
|
{ |
23
|
2 |
|
return $this->compileWhere('Basic', $boolean, compact('column', 'operator', 'value')); |
24
|
|
|
} |
25
|
|
|
|
26
|
3 |
|
public function whereColumn(string $first, string $operator, string $second, string $boolean = 'and'): self |
27
|
|
|
{ |
28
|
3 |
|
return $this->compileWhere('Column', $boolean, compact('first', 'operator', 'second')); |
29
|
|
|
} |
30
|
|
|
|
31
|
5 |
|
public function whereIn(string $column, array $values, string $boolean = 'and', bool $not = false): self |
32
|
|
|
{ |
33
|
5 |
|
return $this->compileWhere($not ? 'NotIn' : 'In', $boolean, compact('column', 'values')); |
34
|
|
|
} |
35
|
|
|
|
36
|
2 |
|
public function whereNotIn(string $column, array $values = [], string $boolean = 'and'): self |
37
|
|
|
{ |
38
|
2 |
|
return $this->whereIn($column, $values, $boolean, true); |
39
|
|
|
} |
40
|
|
|
|
41
|
6 |
|
public function whereNull(string $column, string $boolean = 'and', bool $not = false): self |
42
|
|
|
{ |
43
|
6 |
|
return $this->compileWhere($not ? 'NotNull' : 'Null', $boolean, compact('column')); |
44
|
|
|
} |
45
|
|
|
|
46
|
2 |
|
public function whereBetween(string $column, array $values = [], string $boolean = 'and', bool $not = false): self |
47
|
|
|
{ |
48
|
2 |
|
return $this->compileWhere('Between', $boolean, compact('column', 'values', 'not')); |
49
|
|
|
} |
50
|
|
|
|
51
|
1 |
|
public function whereNotBetween(string $column, array $values = [], string $boolean = 'and'): self |
52
|
|
|
{ |
53
|
1 |
|
return $this->whereBetween($column, $values, $boolean, true); |
54
|
|
|
} |
55
|
|
|
|
56
|
2 |
|
public function whereNotNull(string $column, string $boolean = 'and'): self |
57
|
|
|
{ |
58
|
2 |
|
return $this->whereNull($column, $boolean, true); |
59
|
|
|
} |
60
|
|
|
|
61
|
18 |
|
protected function compileWhere(string $type, string $boolean, array $parameters = []): self |
62
|
|
|
{ |
63
|
18 |
|
$this->attributes['wheres'][] = array_merge(compact('type', 'boolean'), $parameters); |
64
|
18 |
|
return $this; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|