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 | 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 | 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 | 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 | 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 | 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 | 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 | public function withCount($relations) |
||
116 | |||
117 | /** |
||
118 | * Merge the where constraints from another query to the current query. |
||
119 | * |
||
120 | * @param \Illuminate\Database\Eloquent\Builder $from |
||
121 | * @return $this |
||
122 | */ |
||
123 | public function mergeConstraintsFrom(Builder $from) |
||
129 | } |
||
130 |
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: