@@ -24,11 +24,13 @@ trait QueriesRelationships
24
24
/**
25
25
* Add a relationship count / exists condition to the query.
26
26
*
27
- * @param \Illuminate\Database\Eloquent\Relations\Relation<*, *, *>|string $relation
27
+ * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
28
+ *
29
+ * @param \Illuminate\Database\Eloquent\Relations\Relation<TRelatedModel, *, *>|string $relation
28
30
* @param string $operator
29
31
* @param int $count
30
32
* @param string $boolean
31
- * @param \Closure|null $callback
33
+ * @param ( \Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>): mixed) |null $callback
32
34
* @return $this
33
35
*
34
36
* @throws \RuntimeException
@@ -79,7 +81,7 @@ public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', ?
79
81
* @param string $operator
80
82
* @param int $count
81
83
* @param string $boolean
82
- * @param \Closure|null $callback
84
+ * @param ( \Closure(\Illuminate\Database\Eloquent\Builder<*>): mixed) |null $callback
83
85
* @return $this
84
86
*/
85
87
protected function hasNested ($ relations , $ operator = '>= ' , $ count = 1 , $ boolean = 'and ' , $ callback = null )
@@ -121,9 +123,11 @@ public function orHas($relation, $operator = '>=', $count = 1)
121
123
/**
122
124
* Add a relationship count / exists condition to the query.
123
125
*
124
- * @param \Illuminate\Database\Eloquent\Relations\Relation<*, *, *>|string $relation
126
+ * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
127
+ *
128
+ * @param \Illuminate\Database\Eloquent\Relations\Relation<TRelatedModel, *, *>|string $relation
125
129
* @param string $boolean
126
- * @param \Closure|null $callback
130
+ * @param ( \Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>): mixed) |null $callback
127
131
* @return $this
128
132
*/
129
133
public function doesntHave ($ relation , $ boolean = 'and ' , ?Closure $ callback = null )
@@ -145,8 +149,10 @@ public function orDoesntHave($relation)
145
149
/**
146
150
* Add a relationship count / exists condition to the query with where clauses.
147
151
*
148
- * @param \Illuminate\Database\Eloquent\Relations\Relation<*, *, *>|string $relation
149
- * @param \Closure|null $callback
152
+ * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
153
+ *
154
+ * @param \Illuminate\Database\Eloquent\Relations\Relation<TRelatedModel, *, *>|string $relation
155
+ * @param (\Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>): mixed)|null $callback
150
156
* @param string $operator
151
157
* @param int $count
152
158
* @return $this
@@ -161,8 +167,8 @@ public function whereHas($relation, ?Closure $callback = null, $operator = '>=',
161
167
*
162
168
* Also load the relationship with same condition.
163
169
*
164
- * @param \Illuminate\Database\Eloquent\Relations\Relation<*, *, *>| string $relation
165
- * @param \Closure|null $callback
170
+ * @param string $relation
171
+ * @param ( \Closure(\Illuminate\Database\Eloquent\Builder<*>|\Illuminate\Database\Eloquent\Relations\Relation<*, *, *>): mixed) |null $callback
166
172
* @param string $operator
167
173
* @param int $count
168
174
* @return $this
@@ -176,8 +182,10 @@ public function withWhereHas($relation, ?Closure $callback = null, $operator = '
176
182
/**
177
183
* Add a relationship count / exists condition to the query with where clauses and an "or".
178
184
*
179
- * @param \Illuminate\Database\Eloquent\Relations\Relation<*, *, *>|string $relation
180
- * @param \Closure|null $callback
185
+ * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
186
+ *
187
+ * @param \Illuminate\Database\Eloquent\Relations\Relation<TRelatedModel, *, *>|string $relation
188
+ * @param (\Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>): mixed)|null $callback
181
189
* @param string $operator
182
190
* @param int $count
183
191
* @return $this
@@ -190,8 +198,10 @@ public function orWhereHas($relation, ?Closure $callback = null, $operator = '>=
190
198
/**
191
199
* Add a relationship count / exists condition to the query with where clauses.
192
200
*
193
- * @param \Illuminate\Database\Eloquent\Relations\Relation<*, *, *>|string $relation
194
- * @param \Closure|null $callback
201
+ * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
202
+ *
203
+ * @param \Illuminate\Database\Eloquent\Relations\Relation<TRelatedModel, *, *>|string $relation
204
+ * @param (\Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>): mixed)|null $callback
195
205
* @return $this
196
206
*/
197
207
public function whereDoesntHave ($ relation , ?Closure $ callback = null )
@@ -202,8 +212,10 @@ public function whereDoesntHave($relation, ?Closure $callback = null)
202
212
/**
203
213
* Add a relationship count / exists condition to the query with where clauses and an "or".
204
214
*
205
- * @param \Illuminate\Database\Eloquent\Relations\Relation<*, *, *>|string $relation
206
- * @param \Closure|null $callback
215
+ * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
216
+ *
217
+ * @param \Illuminate\Database\Eloquent\Relations\Relation<TRelatedModel, *, *>|string $relation
218
+ * @param (\Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>): mixed)|null $callback
207
219
* @return $this
208
220
*/
209
221
public function orWhereDoesntHave ($ relation , ?Closure $ callback = null )
@@ -214,12 +226,14 @@ public function orWhereDoesntHave($relation, ?Closure $callback = null)
214
226
/**
215
227
* Add a polymorphic relationship count / exists condition to the query.
216
228
*
217
- * @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation
218
- * @param string|array $types
229
+ * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
230
+ *
231
+ * @param \Illuminate\Database\Eloquent\Relations\MorphTo<TRelatedModel, *>|string $relation
232
+ * @param string|array<int, string> $types
219
233
* @param string $operator
220
234
* @param int $count
221
235
* @param string $boolean
222
- * @param \Closure|null $callback
236
+ * @param ( \Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>, string): mixed) |null $callback
223
237
* @return $this
224
238
*/
225
239
public function hasMorph ($ relation , $ types , $ operator = '>= ' , $ count = 1 , $ boolean = 'and ' , ?Closure $ callback = null )
@@ -292,7 +306,7 @@ protected function getBelongsToRelation(MorphTo $relation, $type)
292
306
* Add a polymorphic relationship count / exists condition to the query with an "or".
293
307
*
294
308
* @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation
295
- * @param string|array $types
309
+ * @param string|array<int, string> $types
296
310
* @param string $operator
297
311
* @param int $count
298
312
* @return $this
@@ -305,10 +319,12 @@ public function orHasMorph($relation, $types, $operator = '>=', $count = 1)
305
319
/**
306
320
* Add a polymorphic relationship count / exists condition to the query.
307
321
*
308
- * @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation
309
- * @param string|array $types
322
+ * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
323
+ *
324
+ * @param \Illuminate\Database\Eloquent\Relations\MorphTo<TRelatedModel, *>|string $relation
325
+ * @param string|array<int, string> $types
310
326
* @param string $boolean
311
- * @param \Closure|null $callback
327
+ * @param ( \Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>, string): mixed) |null $callback
312
328
* @return $this
313
329
*/
314
330
public function doesntHaveMorph ($ relation , $ types , $ boolean = 'and ' , ?Closure $ callback = null )
@@ -320,7 +336,7 @@ public function doesntHaveMorph($relation, $types, $boolean = 'and', ?Closure $c
320
336
* Add a polymorphic relationship count / exists condition to the query with an "or".
321
337
*
322
338
* @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation
323
- * @param string|array $types
339
+ * @param string|array<int, string> $types
324
340
* @return $this
325
341
*/
326
342
public function orDoesntHaveMorph ($ relation , $ types )
@@ -331,9 +347,11 @@ public function orDoesntHaveMorph($relation, $types)
331
347
/**
332
348
* Add a polymorphic relationship count / exists condition to the query with where clauses.
333
349
*
334
- * @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation
335
- * @param string|array $types
336
- * @param \Closure|null $callback
350
+ * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
351
+ *
352
+ * @param \Illuminate\Database\Eloquent\Relations\MorphTo<TRelatedModel, *>|string $relation
353
+ * @param string|array<int, string> $types
354
+ * @param (\Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>, string): mixed)|null $callback
337
355
* @param string $operator
338
356
* @param int $count
339
357
* @return $this
@@ -346,9 +364,11 @@ public function whereHasMorph($relation, $types, ?Closure $callback = null, $ope
346
364
/**
347
365
* Add a polymorphic relationship count / exists condition to the query with where clauses and an "or".
348
366
*
349
- * @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation
350
- * @param string|array $types
351
- * @param \Closure|null $callback
367
+ * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
368
+ *
369
+ * @param \Illuminate\Database\Eloquent\Relations\MorphTo<TRelatedModel, *>|string $relation
370
+ * @param string|array<int, array> $types
371
+ * @param (\Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>, string): mixed)|null $callback
352
372
* @param string $operator
353
373
* @param int $count
354
374
* @return $this
@@ -361,9 +381,11 @@ public function orWhereHasMorph($relation, $types, ?Closure $callback = null, $o
361
381
/**
362
382
* Add a polymorphic relationship count / exists condition to the query with where clauses.
363
383
*
364
- * @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation
365
- * @param string|array $types
366
- * @param \Closure|null $callback
384
+ * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
385
+ *
386
+ * @param \Illuminate\Database\Eloquent\Relations\MorphTo<TRelatedModel, *>|string $relation
387
+ * @param string|array<int, string> $types
388
+ * @param (\Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>, string): mixed)|null $callback
367
389
* @return $this
368
390
*/
369
391
public function whereDoesntHaveMorph ($ relation , $ types , ?Closure $ callback = null )
@@ -374,9 +396,11 @@ public function whereDoesntHaveMorph($relation, $types, ?Closure $callback = nul
374
396
/**
375
397
* Add a polymorphic relationship count / exists condition to the query with where clauses and an "or".
376
398
*
377
- * @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation
378
- * @param string|array $types
379
- * @param \Closure|null $callback
399
+ * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
400
+ *
401
+ * @param \Illuminate\Database\Eloquent\Relations\MorphTo<TRelatedModel, *>|string $relation
402
+ * @param string|array<int, string> $types
403
+ * @param (\Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>, string): mixed)|null $callback
380
404
* @return $this
381
405
*/
382
406
public function orWhereDoesntHaveMorph ($ relation , $ types , ?Closure $ callback = null )
@@ -387,8 +411,10 @@ public function orWhereDoesntHaveMorph($relation, $types, ?Closure $callback = n
387
411
/**
388
412
* Add a basic where clause to a relationship query.
389
413
*
390
- * @param \Illuminate\Database\Eloquent\Relations\Relation<*, *, *>|string $relation
391
- * @param \Closure|string|array|\Illuminate\Contracts\Database\Query\Expression $column
414
+ * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
415
+ *
416
+ * @param \Illuminate\Database\Eloquent\Relations\Relation<TRelatedModel, *, *>|string $relation
417
+ * @param (\Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>): mixed)|string|array|\Illuminate\Contracts\Database\Query\Expression $column
392
418
* @param mixed $operator
393
419
* @param mixed $value
394
420
* @return $this
@@ -407,8 +433,10 @@ public function whereRelation($relation, $column, $operator = null, $value = nul
407
433
/**
408
434
* Add an "or where" clause to a relationship query.
409
435
*
410
- * @param \Illuminate\Database\Eloquent\Relations\Relation<*, *, *>|string $relation
411
- * @param \Closure|string|array|\Illuminate\Contracts\Database\Query\Expression $column
436
+ * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
437
+ *
438
+ * @param \Illuminate\Database\Eloquent\Relations\Relation<TRelatedModel, *, *>|string $relation
439
+ * @param (\Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>): mixed)|string|array|\Illuminate\Contracts\Database\Query\Expression $column
412
440
* @param mixed $operator
413
441
* @param mixed $value
414
442
* @return $this
@@ -427,8 +455,10 @@ public function orWhereRelation($relation, $column, $operator = null, $value = n
427
455
/**
428
456
* Add a basic count / exists condition to a relationship query.
429
457
*
430
- * @param \Illuminate\Database\Eloquent\Relations\Relation<*, *, *>|string $relation
431
- * @param \Closure|string|array|\Illuminate\Contracts\Database\Query\Expression $column
458
+ * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
459
+ *
460
+ * @param \Illuminate\Database\Eloquent\Relations\Relation<TRelatedModel, *, *>|string $relation
461
+ * @param (\Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>): mixed)|string|array|\Illuminate\Contracts\Database\Query\Expression $column
432
462
* @param mixed $operator
433
463
* @param mixed $value
434
464
* @return $this
@@ -447,8 +477,10 @@ public function whereDoesntHaveRelation($relation, $column, $operator = null, $v
447
477
/**
448
478
* Add an "or where" clause to a relationship query.
449
479
*
450
- * @param \Illuminate\Database\Eloquent\Relations\Relation<*, *, *>|string $relation
451
- * @param \Closure|string|array|\Illuminate\Contracts\Database\Query\Expression $column
480
+ * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
481
+ *
482
+ * @param \Illuminate\Database\Eloquent\Relations\Relation<TRelatedModel, *, *>|string $relation
483
+ * @param (\Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>): mixed)|string|array|\Illuminate\Contracts\Database\Query\Expression $column
452
484
* @param mixed $operator
453
485
* @param mixed $value
454
486
* @return $this
@@ -467,9 +499,11 @@ public function orWhereDoesntHaveRelation($relation, $column, $operator = null,
467
499
/**
468
500
* Add a polymorphic relationship condition to the query with a where clause.
469
501
*
470
- * @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation
471
- * @param string|array $types
472
- * @param \Closure|string|array|\Illuminate\Contracts\Database\Query\Expression $column
502
+ * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
503
+ *
504
+ * @param \Illuminate\Database\Eloquent\Relations\MorphTo<TRelatedModel, *>|string $relation
505
+ * @param string|array<int, string> $types
506
+ * @param (\Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>): mixed)|string|array|\Illuminate\Contracts\Database\Query\Expression $column
473
507
* @param mixed $operator
474
508
* @param mixed $value
475
509
* @return $this
@@ -484,9 +518,11 @@ public function whereMorphRelation($relation, $types, $column, $operator = null,
484
518
/**
485
519
* Add a polymorphic relationship condition to the query with an "or where" clause.
486
520
*
487
- * @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation
488
- * @param string|array $types
489
- * @param \Closure|string|array|\Illuminate\Contracts\Database\Query\Expression $column
521
+ * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
522
+ *
523
+ * @param \Illuminate\Database\Eloquent\Relations\MorphTo<TRelatedModel, *>|string $relation
524
+ * @param string|array<int, string> $types
525
+ * @param (\Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>): mixed)|string|array|\Illuminate\Contracts\Database\Query\Expression $column
490
526
* @param mixed $operator
491
527
* @param mixed $value
492
528
* @return $this
@@ -501,9 +537,11 @@ public function orWhereMorphRelation($relation, $types, $column, $operator = nul
501
537
/**
502
538
* Add a polymorphic relationship condition to the query with a doesn't have clause.
503
539
*
504
- * @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation
505
- * @param string|array $types
506
- * @param \Closure|string|array|\Illuminate\Contracts\Database\Query\Expression $column
540
+ * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
541
+ *
542
+ * @param \Illuminate\Database\Eloquent\Relations\MorphTo<TRelatedModel, *>|string $relation
543
+ * @param string|array<int, string> $types
544
+ * @param (\Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>): mixed)|string|array|\Illuminate\Contracts\Database\Query\Expression $column
507
545
* @param mixed $operator
508
546
* @param mixed $value
509
547
* @return $this
@@ -518,9 +556,11 @@ public function whereMorphDoesntHaveRelation($relation, $types, $column, $operat
518
556
/**
519
557
* Add a polymorphic relationship condition to the query with an "or doesn't have" clause.
520
558
*
521
- * @param \Illuminate\Database\Eloquent\Relations\MorphTo<*, *>|string $relation
522
- * @param string|array $types
523
- * @param \Closure|string|array|\Illuminate\Contracts\Database\Query\Expression $column
559
+ * @template TRelatedModel of \Illuminate\Database\Eloquent\Model
560
+ *
561
+ * @param \Illuminate\Database\Eloquent\Relations\MorphTo<TRelatedModel, *>|string $relation
562
+ * @param string|array<int, string> $types
563
+ * @param (\Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>): mixed)|string|array|\Illuminate\Contracts\Database\Query\Expression $column
524
564
* @param mixed $operator
525
565
* @param mixed $value
526
566
* @return $this
0 commit comments