1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
<?php namespace Illuminate\Database\Query;
class JoinClause {
/**
* The type of join being performed.
*
* @var string
*/
public $type;
/**
* The table the join clause is joining to.
*
* @var string
*/
public $table;
/**
* The "on" clauses for the join.
*
* @var array
*/
public $clauses = array();
/**
* The "on" bindings for the join.
*
* @var array
*/
public $bindings = array();
/**
* Create a new join clause instance.
*
* @param string $type
* @param string $table
* @return void
*/
public function __construct($type, $table)
{
$this->type = $type;
$this->table = $table;
}
/**
* Add an "on" clause to the join.
*
* @param string $first
* @param string $operator
* @param string $second
* @param string $boolean
* @param bool $where
* @return $this
*/
public function on($first, $operator, $second, $boolean = 'and', $where = false)
{
$this->clauses[] = compact('first', 'operator', 'second', 'boolean', 'where');
if ($where) $this->bindings[] = $second;
return $this;
}
/**
* Add an "or on" clause to the join.
*
* @param string $first
* @param string $operator
* @param string $second
* @return \Illuminate\Database\Query\JoinClause
*/
public function orOn($first, $operator, $second)
{
return $this->on($first, $operator, $second, 'or');
}
/**
* Add an "on where" clause to the join.
*
* @param string $first
* @param string $operator
* @param string $second
* @param string $boolean
* @return \Illuminate\Database\Query\JoinClause
*/
public function where($first, $operator, $second, $boolean = 'and')
{
return $this->on($first, $operator, $second, $boolean, true);
}
/**
* Add an "or on where" clause to the join.
*
* @param string $first
* @param string $operator
* @param string $second
* @return \Illuminate\Database\Query\JoinClause
*/
public function orWhere($first, $operator, $second)
{
return $this->on($first, $operator, $second, 'or', true);
}
/**
* Add an "on where is null" clause to the join
*
* @param $column
* @param string $boolean
* @return \Illuminate\Database\Query\JoinClause
*/
public function whereNull($column, $boolean = 'and')
{
return $this->on($column, 'is', new Expression('null'), $boolean, false);
}
}
|