1 | <?php |
||
9 | trait QueriesRelationships |
||
10 | { |
||
11 | /** |
||
12 | * Add a relationship count / exists condition to the query. |
||
13 | * |
||
14 | * @param string $relation |
||
15 | * @param string $operator |
||
16 | * @param int $count |
||
17 | * @param string $boolean |
||
18 | * @param \Closure|null $callback |
||
19 | * @return $this |
||
20 | */ |
||
21 | 1 | public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', Closure $callback = null) |
|
27 | |||
28 | /** |
||
29 | * Add a relationship count / exists condition to the query with an "or". |
||
30 | * |
||
31 | * @param string $relation |
||
32 | * @param string $operator |
||
33 | * @param int $count |
||
34 | * @return $this |
||
35 | */ |
||
36 | 1 | public function orHas($relation, $operator = '>=', $count = 1) |
|
42 | |||
43 | /** |
||
44 | * Add a relationship count / exists condition to the query. |
||
45 | * |
||
46 | * @param string $relation |
||
47 | * @param string $boolean |
||
48 | * @param \Closure|null $callback |
||
49 | * @return $this |
||
50 | */ |
||
51 | 1 | public function doesntHave($relation, $boolean = 'and', Closure $callback = null) |
|
57 | |||
58 | /** |
||
59 | * Add a relationship count / exists condition to the query with where clauses. |
||
60 | * |
||
61 | * @param string $relation |
||
62 | * @param \Closure|null $callback |
||
63 | * @param string $operator |
||
64 | * @param int $count |
||
65 | * @return $this |
||
66 | */ |
||
67 | 1 | public function whereHas($relation, Closure $callback = null, $operator = '>=', $count = 1) |
|
73 | |||
74 | /** |
||
75 | * Add a relationship count / exists condition to the query with where clauses and an "or". |
||
76 | * |
||
77 | * @param string $relation |
||
78 | * @param \Closure|null $callback |
||
79 | * @param string $operator |
||
80 | * @param int $count |
||
81 | * @return $this |
||
82 | */ |
||
83 | 1 | public function orWhereHas($relation, Closure $callback = null, $operator = '>=', $count = 1) |
|
89 | |||
90 | /** |
||
91 | * Add a relationship count / exists condition to the query with where clauses. |
||
92 | * |
||
93 | * @param string $relation |
||
94 | * @param \Closure|null $callback |
||
95 | * @return $this |
||
96 | */ |
||
97 | 1 | public function whereDoesntHave($relation, Closure $callback = null) |
|
103 | |||
104 | /** |
||
105 | * Add subselect queries to count the relations. |
||
106 | * |
||
107 | * @param mixed $relations |
||
108 | * @return $this |
||
109 | */ |
||
110 | 1 | public function withCount($relations) |
|
116 | |||
117 | /** |
||
118 | * Add subselect queries to include the max of the relation's column. |
||
119 | * |
||
120 | * @param string|array $relation |
||
121 | * @param string $column |
||
122 | * @return $this |
||
123 | 1 | */ |
|
124 | public function withMax($relation, $column) |
||
130 | |||
131 | /** |
||
132 | * Add subselect queries to include the min of the relation's column. |
||
133 | * |
||
134 | * @param string|array $relation |
||
135 | * @param string $column |
||
136 | * @return $this |
||
137 | */ |
||
138 | public function withMin($relation, $column) |
||
144 | |||
145 | /** |
||
146 | * Add subselect queries to include the sum of the relation's column. |
||
147 | * |
||
148 | * @param string|array $relation |
||
149 | * @param string $column |
||
150 | * @return $this |
||
151 | */ |
||
152 | public function withSum($relation, $column) |
||
158 | |||
159 | /** |
||
160 | * Add subselect queries to include the average of the relation's column. |
||
161 | * |
||
162 | * @param string|array $relation |
||
163 | * @param string $column |
||
164 | * @return $this |
||
165 | */ |
||
166 | public function withAvg($relation, $column) |
||
170 | |||
171 | /** |
||
172 | * Merge the where constraints from another query to the current query. |
||
173 | * |
||
174 | * @param \Illuminate\Database\Eloquent\Builder $from |
||
175 | * @return $this |
||
176 | */ |
||
177 | public function mergeConstraintsFrom(Builder $from) |
||
183 | } |
||
184 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: