44use Illuminate \Database \Eloquent \Relations \Relation ;
55use MongoCursor ;
66
7- class Builder extends EloquentBuilder {
8-
7+ class Builder extends EloquentBuilder
8+ {
99 /**
1010 * The methods that should be returned from query builder.
1111 *
@@ -26,8 +26,7 @@ public function update(array $values)
2626 {
2727 // Intercept operations on embedded models and delegate logic
2828 // to the parent relation instance.
29- if ($ relation = $ this ->model ->getParentRelation ())
30- {
29+ if ($ relation = $ this ->model ->getParentRelation ()) {
3130 $ relation ->performUpdate ($ this ->model , $ values );
3231
3332 return 1 ;
@@ -46,8 +45,7 @@ public function insert(array $values)
4645 {
4746 // Intercept operations on embedded models and delegate logic
4847 // to the parent relation instance.
49- if ($ relation = $ this ->model ->getParentRelation ())
50- {
48+ if ($ relation = $ this ->model ->getParentRelation ()) {
5149 $ relation ->performInsert ($ this ->model , $ values );
5250
5351 return true ;
@@ -67,8 +65,7 @@ public function insertGetId(array $values, $sequence = null)
6765 {
6866 // Intercept operations on embedded models and delegate logic
6967 // to the parent relation instance.
70- if ($ relation = $ this ->model ->getParentRelation ())
71- {
68+ if ($ relation = $ this ->model ->getParentRelation ()) {
7269 $ relation ->performInsert ($ this ->model , $ values );
7370
7471 return $ this ->model ->getKey ();
@@ -86,8 +83,7 @@ public function delete()
8683 {
8784 // Intercept operations on embedded models and delegate logic
8885 // to the parent relation instance.
89- if ($ relation = $ this ->model ->getParentRelation ())
90- {
86+ if ($ relation = $ this ->model ->getParentRelation ()) {
9187 $ relation ->performDelete ($ this ->model );
9288
9389 return $ this ->model ->getKey ();
@@ -108,8 +104,7 @@ public function increment($column, $amount = 1, array $extra = [])
108104 {
109105 // Intercept operations on embedded models and delegate logic
110106 // to the parent relation instance.
111- if ($ relation = $ this ->model ->getParentRelation ())
112- {
107+ if ($ relation = $ this ->model ->getParentRelation ()) {
113108 $ value = $ this ->model ->{$ column };
114109
115110 // When doing increment and decrements, Eloquent will automatically
@@ -139,8 +134,7 @@ public function decrement($column, $amount = 1, array $extra = [])
139134 {
140135 // Intercept operations on embedded models and delegate logic
141136 // to the parent relation instance.
142- if ($ relation = $ this ->model ->getParentRelation ())
143- {
137+ if ($ relation = $ this ->model ->getParentRelation ()) {
144138 $ value = $ this ->model ->{$ column };
145139
146140 // When doing increment and decrements, Eloquent will automatically
@@ -174,13 +168,13 @@ protected function addHasWhere(EloquentBuilder $hasQuery, Relation $relation, $o
174168 $ relationCount = array_count_values ($ query ->lists ($ relation ->getHasCompareKey ()));
175169
176170 // Remove unwanted related objects based on the operator and count.
177- $ relationCount = array_filter ($ relationCount , function ($ counted ) use ($ count , $ operator )
178- {
171+ $ relationCount = array_filter ($ relationCount , function ($ counted ) use ($ count , $ operator ) {
179172 // If we are comparing to 0, we always need all results.
180- if ($ count == 0 ) return true ;
173+ if ($ count == 0 ) {
174+ return true ;
175+ }
181176
182- switch ($ operator )
183- {
177+ switch ($ operator ) {
184178 case '>= ' :
185179 case '< ' :
186180 return $ counted >= $ count ;
@@ -197,7 +191,9 @@ protected function addHasWhere(EloquentBuilder $hasQuery, Relation $relation, $o
197191 $ not = in_array ($ operator , ['< ' , '<= ' , '!= ' ]);
198192
199193 // If we are comparing to 0, we need an additional $not flip.
200- if ($ count == 0 ) $ not = !$ not ;
194+ if ($ count == 0 ) {
195+ $ not = !$ not ;
196+ }
201197
202198 // All related ids.
203199 $ relatedIds = array_keys ($ relationCount );
@@ -218,16 +214,14 @@ public function raw($expression = null)
218214 $ results = $ this ->query ->raw ($ expression );
219215
220216 // Convert MongoCursor results to a collection of models.
221- if ($ results instanceof MongoCursor)
222- {
217+ if ($ results instanceof MongoCursor) {
223218 $ results = iterator_to_array ($ results , false );
224219
225220 return $ this ->model ->hydrate ($ results );
226221 }
227222
228223 // The result is a single object.
229- elseif (is_array ($ results ) and array_key_exists ('_id ' , $ results ))
230- {
224+ elseif (is_array ($ results ) and array_key_exists ('_id ' , $ results )) {
231225 $ model = $ this ->model ->newFromBuilder ($ results );
232226
233227 $ model ->setConnection ($ this ->model ->getConnection ());
@@ -237,5 +231,4 @@ public function raw($expression = null)
237231
238232 return $ results ;
239233 }
240-
241234}
0 commit comments