@@ -28,17 +28,18 @@ public function powerJoin(): Closure
2828 {
2929 return function ($ table , $ first , $ operator = null , $ second = null , $ type = 'inner ' , $ where = false ): static {
3030 $ model = $ operator instanceof Model ? $ operator : null ;
31- $ join = $ this ->newPowerJoinClause ($ this ->query , $ type , $ table , $ model );
31+ /** @var PowerJoinClause $join */
32+ $ join = $ this ->newPowerJoinClause ($ this ->getQuery (), $ type , $ table , $ model );
3233
3334 // If the first "column" of the join is really a Closure instance the developer
3435 // is trying to build a join with a complex "on" clause containing more than
3536 // one condition, so we'll add the join and call a Closure with the query.
3637 if ($ first instanceof Closure) {
3738 $ first ($ join );
3839
39- $ this ->query ->joins [] = $ join ;
40+ $ this ->getQuery () ->joins [] = $ join ;
4041
41- $ this ->query ->addBinding ($ join ->getBindings (), 'join ' );
42+ $ this ->getQuery () ->addBinding ($ join ->getBindings (), 'join ' );
4243 }
4344
4445 // If the column is simply a string, we can assume the join simply has a basic
@@ -47,9 +48,9 @@ public function powerJoin(): Closure
4748 else {
4849 $ method = $ where ? 'where ' : 'on ' ;
4950
50- $ this ->query ->joins [] = $ join ->$ method ($ first , $ operator , $ second );
51+ $ this ->getQuery () ->joins [] = $ join ->$ method ($ first , $ operator , $ second );
5152
52- $ this ->query ->addBinding ($ join ->getBindings (), 'join ' );
53+ $ this ->getQuery () ->addBinding ($ join ->getBindings (), 'join ' );
5354 }
5455
5556 return $ this ;
@@ -200,28 +201,28 @@ public function joinRelation(): Closure
200201
201202 public function leftJoinRelationship (): Closure
202203 {
203- return function ($ relation , $ callback = null , $ useAlias = false , bool $ disableExtraConditions = false ) {
204+ return function (string $ relation , $ callback = null , $ useAlias = false , bool $ disableExtraConditions = false ) {
204205 return $ this ->joinRelationship ($ relation , $ callback , 'leftJoin ' , $ useAlias , $ disableExtraConditions );
205206 };
206207 }
207208
208209 public function leftJoinRelation (): Closure
209210 {
210- return function ($ relation , $ callback = null , $ useAlias = false , bool $ disableExtraConditions = false ) {
211+ return function (string $ relation , $ callback = null , $ useAlias = false , bool $ disableExtraConditions = false ) {https: //github.com/kirschbaum-development/eloquent-power-joins
211212 return $ this ->joinRelationship ($ relation , $ callback , 'leftJoin ' , $ useAlias , $ disableExtraConditions );
212213 };
213214 }
214215
215216 public function rightJoinRelationship (): Closure
216217 {
217- return function ($ relation , $ callback = null , $ useAlias = false , bool $ disableExtraConditions = false ) {
218+ return function (string $ relation , $ callback = null , $ useAlias = false , bool $ disableExtraConditions = false ) {
218219 return $ this ->joinRelationship ($ relation , $ callback , 'rightJoin ' , $ useAlias , $ disableExtraConditions );
219220 };
220221 }
221222
222223 public function rightJoinRelation (): Closure
223224 {
224- return function ($ relation , $ callback = null , $ useAlias = false , bool $ disableExtraConditions = false ) {
225+ return function (string $ relation , $ callback = null , $ useAlias = false , bool $ disableExtraConditions = false ) {
225226 return $ this ->joinRelationship ($ relation , $ callback , 'rightJoin ' , $ useAlias , $ disableExtraConditions );
226227 };
227228 }
@@ -314,7 +315,7 @@ public function joinNestedRelationship(): Closure
314315 */
315316 public function orderByPowerJoins (): Closure
316317 {
317- return function ($ sort , $ direction = 'asc ' , $ aggregation = null , $ joinType = 'join ' ) {
318+ return function ($ sort , string $ direction = 'asc ' , $ aggregation = null , $ joinType = 'join ' ) {
318319 if (is_array ($ sort )) {
319320 $ relationships = explode ('. ' , $ sort [0 ]);
320321 $ column = $ sort [1 ];
@@ -366,7 +367,7 @@ public function orderByPowerJoins(): Closure
366367
367368 public function orderByLeftPowerJoins (): Closure
368369 {
369- return function ($ sort , $ direction = 'asc ' ) {
370+ return function ($ sort , string $ direction = 'asc ' ) {
370371 return $ this ->orderByPowerJoins ($ sort , $ direction , null , 'leftJoin ' );
371372 };
372373 }
@@ -376,14 +377,14 @@ public function orderByLeftPowerJoins(): Closure
376377 */
377378 public function orderByPowerJoinsCount (): Closure
378379 {
379- return function ($ sort , $ direction = 'asc ' ) {
380+ return function ($ sort , string $ direction = 'asc ' ) {
380381 return $ this ->orderByPowerJoins ($ sort , $ direction , 'COUNT ' );
381382 };
382383 }
383384
384385 public function orderByLeftPowerJoinsCount (): Closure
385386 {
386- return function ($ sort , $ direction = 'asc ' ) {
387+ return function ($ sort , string $ direction = 'asc ' ) {
387388 return $ this ->orderByPowerJoins ($ sort , $ direction , 'COUNT ' , 'leftJoin ' );
388389 };
389390 }
@@ -393,14 +394,14 @@ public function orderByLeftPowerJoinsCount(): Closure
393394 */
394395 public function orderByPowerJoinsSum (): Closure
395396 {
396- return function ($ sort , $ direction = 'asc ' ) {
397+ return function ($ sort , string $ direction = 'asc ' ) {
397398 return $ this ->orderByPowerJoins ($ sort , $ direction , 'SUM ' );
398399 };
399400 }
400401
401402 public function orderByLeftPowerJoinsSum (): Closure
402403 {
403- return function ($ sort , $ direction = 'asc ' ) {
404+ return function ($ sort , string $ direction = 'asc ' ) {
404405 return $ this ->orderByPowerJoins ($ sort , $ direction , 'SUM ' , 'leftJoin ' );
405406 };
406407 }
@@ -410,14 +411,14 @@ public function orderByLeftPowerJoinsSum(): Closure
410411 */
411412 public function orderByPowerJoinsAvg (): Closure
412413 {
413- return function ($ sort , $ direction = 'asc ' ) {
414+ return function ($ sort , string $ direction = 'asc ' ) {
414415 return $ this ->orderByPowerJoins ($ sort , $ direction , 'AVG ' );
415416 };
416417 }
417418
418419 public function orderByLeftPowerJoinsAvg (): Closure
419420 {
420- return function ($ sort , $ direction = 'asc ' ) {
421+ return function ($ sort , string $ direction = 'asc ' ) {
421422 return $ this ->orderByPowerJoins ($ sort , $ direction , 'AVG ' , 'leftJoin ' );
422423 };
423424 }
@@ -427,14 +428,14 @@ public function orderByLeftPowerJoinsAvg(): Closure
427428 */
428429 public function orderByPowerJoinsMin (): Closure
429430 {
430- return function ($ sort , $ direction = 'asc ' ) {
431+ return function ($ sort , string $ direction = 'asc ' ) {
431432 return $ this ->orderByPowerJoins ($ sort , $ direction , 'MIN ' );
432433 };
433434 }
434435
435436 public function orderByLeftPowerJoinsMin (): Closure
436437 {
437- return function ($ sort , $ direction = 'asc ' ) {
438+ return function ($ sort , string $ direction = 'asc ' ) {
438439 return $ this ->orderByPowerJoins ($ sort , $ direction , 'MIN ' , 'leftJoin ' );
439440 };
440441 }
@@ -444,14 +445,14 @@ public function orderByLeftPowerJoinsMin(): Closure
444445 */
445446 public function orderByPowerJoinsMax (): Closure
446447 {
447- return function ($ sort , $ direction = 'asc ' ) {
448+ return function ($ sort , string $ direction = 'asc ' ) {
448449 return $ this ->orderByPowerJoins ($ sort , $ direction , 'MAX ' );
449450 };
450451 }
451452
452453 public function orderByLeftPowerJoinsMax (): Closure
453454 {
454- return function ($ sort , $ direction = 'asc ' ) {
455+ return function ($ sort , string $ direction = 'asc ' ) {
455456 return $ this ->orderByPowerJoins ($ sort , $ direction , 'MAX ' , 'leftJoin ' );
456457 };
457458 }
@@ -487,7 +488,7 @@ public function powerJoinHas(): Closure
487488
488489 public function hasNestedUsingJoins (): Closure
489490 {
490- return function ($ relations , $ operator = '>= ' , $ count = 1 , $ boolean = 'and ' , Closure |array $ callback = null ): static {
491+ return function (string $ relations , $ operator = '>= ' , $ count = 1 , $ boolean = 'and ' , Closure |array $ callback = null ): static {
491492 $ relations = explode ('. ' , $ relations );
492493
493494 /** @var Relation */
@@ -516,15 +517,15 @@ public function hasNestedUsingJoins(): Closure
516517
517518 public function powerJoinDoesntHave (): Closure
518519 {
519- return function ($ relation , $ boolean = 'and ' , Closure $ callback = null ) {
520+ return function (string $ relation , $ boolean = 'and ' , Closure $ callback = null ) {
520521 return $ this ->powerJoinHas ($ relation , '< ' , 1 , $ boolean , $ callback );
521522 };
522523
523524 }
524525
525526 public function powerJoinWhereHas (): Closure
526527 {
527- return function ($ relation , $ callback = null , $ operator = '>= ' , $ count = 1 ) {
528+ return function (string $ relation , $ callback = null , $ operator = '>= ' , $ count = 1 ) {
528529 return $ this ->powerJoinHas ($ relation , $ operator , $ count , 'and ' , $ callback );
529530 };
530531 }
0 commit comments