@@ -91,11 +91,6 @@ abstract class Relation extends Field implements Form
91
91
*/
92
92
protected ?Closure $ aggregateResolver = null ;
93
93
94
- /**
95
- * Determine whether the relation values are aggregated.
96
- */
97
- protected bool $ aggregated = false ;
98
-
99
94
/**
100
95
* The option group resolver.
101
96
*/
@@ -390,7 +385,7 @@ public function resolveDisplay(Model $related): ?string
390
385
*/
391
386
public function getValue (Model $ model ): mixed
392
387
{
393
- if ($ this ->aggregated ) {
388
+ if (is_callable ( $ this ->aggregateResolver ) ) {
394
389
return parent ::getValue ($ model );
395
390
}
396
391
@@ -412,11 +407,14 @@ public function resolveFormat(Request $request, Model $model): ?string
412
407
$ this ->formatResolver = function (Request $ request , Model $ model ): mixed {
413
408
$ default = $ this ->getValue ($ model );
414
409
415
- if ($ this ->aggregated ) {
416
- return $ default ;
410
+ if (is_callable ( $ this ->aggregateResolver ) ) {
411
+ return ( string ) $ default ;
417
412
}
418
413
419
- return Collection::wrap ($ default )->map (fn (Model $ related ): ?string => $ this ->formatRelated ($ request , $ model , $ related ))->filter ()->join (', ' );
414
+ return Collection::wrap ($ default )
415
+ ->map (fn (Model $ related ): ?string => $ this ->formatRelated ($ request , $ model , $ related ))
416
+ ->filter ()
417
+ ->join (', ' );
420
418
};
421
419
}
422
420
@@ -540,8 +538,6 @@ public function aggregate(string $fn = 'count', string $column = '*'): static
540
538
$ column === '* ' ? '' : sprintf ('_%s ' , $ column )
541
539
));
542
540
543
- $ this ->aggregated = true ;
544
-
545
541
return $ query ->withAggregate ($ this ->getRelationName (), $ column , $ fn );
546
542
};
547
543
0 commit comments