@@ -28,17 +28,18 @@ public function powerJoin(): Closure
28
28
{
29
29
return function ($ table , $ first , $ operator = null , $ second = null , $ type = 'inner ' , $ where = false ): static {
30
30
$ 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 );
32
33
33
34
// If the first "column" of the join is really a Closure instance the developer
34
35
// is trying to build a join with a complex "on" clause containing more than
35
36
// one condition, so we'll add the join and call a Closure with the query.
36
37
if ($ first instanceof Closure) {
37
38
$ first ($ join );
38
39
39
- $ this ->query ->joins [] = $ join ;
40
+ $ this ->getQuery () ->joins [] = $ join ;
40
41
41
- $ this ->query ->addBinding ($ join ->getBindings (), 'join ' );
42
+ $ this ->getQuery () ->addBinding ($ join ->getBindings (), 'join ' );
42
43
}
43
44
44
45
// If the column is simply a string, we can assume the join simply has a basic
@@ -47,9 +48,9 @@ public function powerJoin(): Closure
47
48
else {
48
49
$ method = $ where ? 'where ' : 'on ' ;
49
50
50
- $ this ->query ->joins [] = $ join ->$ method ($ first , $ operator , $ second );
51
+ $ this ->getQuery () ->joins [] = $ join ->$ method ($ first , $ operator , $ second );
51
52
52
- $ this ->query ->addBinding ($ join ->getBindings (), 'join ' );
53
+ $ this ->getQuery () ->addBinding ($ join ->getBindings (), 'join ' );
53
54
}
54
55
55
56
return $ this ;
@@ -200,28 +201,28 @@ public function joinRelation(): Closure
200
201
201
202
public function leftJoinRelationship (): Closure
202
203
{
203
- return function ($ relation , $ callback = null , $ useAlias = false , bool $ disableExtraConditions = false ) {
204
+ return function (string $ relation , $ callback = null , $ useAlias = false , bool $ disableExtraConditions = false ) {
204
205
return $ this ->joinRelationship ($ relation , $ callback , 'leftJoin ' , $ useAlias , $ disableExtraConditions );
205
206
};
206
207
}
207
208
208
209
public function leftJoinRelation (): Closure
209
210
{
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
211
212
return $ this ->joinRelationship ($ relation , $ callback , 'leftJoin ' , $ useAlias , $ disableExtraConditions );
212
213
};
213
214
}
214
215
215
216
public function rightJoinRelationship (): Closure
216
217
{
217
- return function ($ relation , $ callback = null , $ useAlias = false , bool $ disableExtraConditions = false ) {
218
+ return function (string $ relation , $ callback = null , $ useAlias = false , bool $ disableExtraConditions = false ) {
218
219
return $ this ->joinRelationship ($ relation , $ callback , 'rightJoin ' , $ useAlias , $ disableExtraConditions );
219
220
};
220
221
}
221
222
222
223
public function rightJoinRelation (): Closure
223
224
{
224
- return function ($ relation , $ callback = null , $ useAlias = false , bool $ disableExtraConditions = false ) {
225
+ return function (string $ relation , $ callback = null , $ useAlias = false , bool $ disableExtraConditions = false ) {
225
226
return $ this ->joinRelationship ($ relation , $ callback , 'rightJoin ' , $ useAlias , $ disableExtraConditions );
226
227
};
227
228
}
@@ -314,7 +315,7 @@ public function joinNestedRelationship(): Closure
314
315
*/
315
316
public function orderByPowerJoins (): Closure
316
317
{
317
- return function ($ sort , $ direction = 'asc ' , $ aggregation = null , $ joinType = 'join ' ) {
318
+ return function ($ sort , string $ direction = 'asc ' , $ aggregation = null , $ joinType = 'join ' ) {
318
319
if (is_array ($ sort )) {
319
320
$ relationships = explode ('. ' , $ sort [0 ]);
320
321
$ column = $ sort [1 ];
@@ -366,7 +367,7 @@ public function orderByPowerJoins(): Closure
366
367
367
368
public function orderByLeftPowerJoins (): Closure
368
369
{
369
- return function ($ sort , $ direction = 'asc ' ) {
370
+ return function ($ sort , string $ direction = 'asc ' ) {
370
371
return $ this ->orderByPowerJoins ($ sort , $ direction , null , 'leftJoin ' );
371
372
};
372
373
}
@@ -376,14 +377,14 @@ public function orderByLeftPowerJoins(): Closure
376
377
*/
377
378
public function orderByPowerJoinsCount (): Closure
378
379
{
379
- return function ($ sort , $ direction = 'asc ' ) {
380
+ return function ($ sort , string $ direction = 'asc ' ) {
380
381
return $ this ->orderByPowerJoins ($ sort , $ direction , 'COUNT ' );
381
382
};
382
383
}
383
384
384
385
public function orderByLeftPowerJoinsCount (): Closure
385
386
{
386
- return function ($ sort , $ direction = 'asc ' ) {
387
+ return function ($ sort , string $ direction = 'asc ' ) {
387
388
return $ this ->orderByPowerJoins ($ sort , $ direction , 'COUNT ' , 'leftJoin ' );
388
389
};
389
390
}
@@ -393,14 +394,14 @@ public function orderByLeftPowerJoinsCount(): Closure
393
394
*/
394
395
public function orderByPowerJoinsSum (): Closure
395
396
{
396
- return function ($ sort , $ direction = 'asc ' ) {
397
+ return function ($ sort , string $ direction = 'asc ' ) {
397
398
return $ this ->orderByPowerJoins ($ sort , $ direction , 'SUM ' );
398
399
};
399
400
}
400
401
401
402
public function orderByLeftPowerJoinsSum (): Closure
402
403
{
403
- return function ($ sort , $ direction = 'asc ' ) {
404
+ return function ($ sort , string $ direction = 'asc ' ) {
404
405
return $ this ->orderByPowerJoins ($ sort , $ direction , 'SUM ' , 'leftJoin ' );
405
406
};
406
407
}
@@ -410,14 +411,14 @@ public function orderByLeftPowerJoinsSum(): Closure
410
411
*/
411
412
public function orderByPowerJoinsAvg (): Closure
412
413
{
413
- return function ($ sort , $ direction = 'asc ' ) {
414
+ return function ($ sort , string $ direction = 'asc ' ) {
414
415
return $ this ->orderByPowerJoins ($ sort , $ direction , 'AVG ' );
415
416
};
416
417
}
417
418
418
419
public function orderByLeftPowerJoinsAvg (): Closure
419
420
{
420
- return function ($ sort , $ direction = 'asc ' ) {
421
+ return function ($ sort , string $ direction = 'asc ' ) {
421
422
return $ this ->orderByPowerJoins ($ sort , $ direction , 'AVG ' , 'leftJoin ' );
422
423
};
423
424
}
@@ -427,14 +428,14 @@ public function orderByLeftPowerJoinsAvg(): Closure
427
428
*/
428
429
public function orderByPowerJoinsMin (): Closure
429
430
{
430
- return function ($ sort , $ direction = 'asc ' ) {
431
+ return function ($ sort , string $ direction = 'asc ' ) {
431
432
return $ this ->orderByPowerJoins ($ sort , $ direction , 'MIN ' );
432
433
};
433
434
}
434
435
435
436
public function orderByLeftPowerJoinsMin (): Closure
436
437
{
437
- return function ($ sort , $ direction = 'asc ' ) {
438
+ return function ($ sort , string $ direction = 'asc ' ) {
438
439
return $ this ->orderByPowerJoins ($ sort , $ direction , 'MIN ' , 'leftJoin ' );
439
440
};
440
441
}
@@ -444,14 +445,14 @@ public function orderByLeftPowerJoinsMin(): Closure
444
445
*/
445
446
public function orderByPowerJoinsMax (): Closure
446
447
{
447
- return function ($ sort , $ direction = 'asc ' ) {
448
+ return function ($ sort , string $ direction = 'asc ' ) {
448
449
return $ this ->orderByPowerJoins ($ sort , $ direction , 'MAX ' );
449
450
};
450
451
}
451
452
452
453
public function orderByLeftPowerJoinsMax (): Closure
453
454
{
454
- return function ($ sort , $ direction = 'asc ' ) {
455
+ return function ($ sort , string $ direction = 'asc ' ) {
455
456
return $ this ->orderByPowerJoins ($ sort , $ direction , 'MAX ' , 'leftJoin ' );
456
457
};
457
458
}
@@ -487,7 +488,7 @@ public function powerJoinHas(): Closure
487
488
488
489
public function hasNestedUsingJoins (): Closure
489
490
{
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 {
491
492
$ relations = explode ('. ' , $ relations );
492
493
493
494
/** @var Relation */
@@ -516,15 +517,15 @@ public function hasNestedUsingJoins(): Closure
516
517
517
518
public function powerJoinDoesntHave (): Closure
518
519
{
519
- return function ($ relation , $ boolean = 'and ' , Closure $ callback = null ) {
520
+ return function (string $ relation , $ boolean = 'and ' , Closure $ callback = null ) {
520
521
return $ this ->powerJoinHas ($ relation , '< ' , 1 , $ boolean , $ callback );
521
522
};
522
523
523
524
}
524
525
525
526
public function powerJoinWhereHas (): Closure
526
527
{
527
- return function ($ relation , $ callback = null , $ operator = '>= ' , $ count = 1 ) {
528
+ return function (string $ relation , $ callback = null , $ operator = '>= ' , $ count = 1 ) {
528
529
return $ this ->powerJoinHas ($ relation , $ operator , $ count , 'and ' , $ callback );
529
530
};
530
531
}
0 commit comments