Skip to content

Commit b8a9d70

Browse files
committed
revert
1 parent c99567a commit b8a9d70

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/Fields/Relation.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ abstract class Relation extends Field implements Form
9494
*/
9595
protected ?Closure $aggregateResolver = null;
9696

97+
/**
98+
* Determine whether the relation values are aggregated.
99+
*/
100+
protected bool $aggregated = false;
101+
97102
/**
98103
* The option group resolver.
99104
*/
@@ -380,15 +385,15 @@ public function resolveDisplay(Model $related): ?string
380385
$this->display($related->getKeyName());
381386
}
382387

383-
return call_user_func_array($this->displayResolver, [$related]);
388+
return (string) call_user_func_array($this->displayResolver, [$related]);
384389
}
385390

386391
/**
387392
* {@inheritdoc}
388393
*/
389394
public function getValue(Model $model): mixed
390395
{
391-
if (is_callable($this->aggregateResolver)) {
396+
if ($this->aggregated) {
392397
return parent::getValue($model);
393398
}
394399

@@ -410,7 +415,7 @@ public function resolveFormat(Request $request, Model $model): ?string
410415
$this->formatResolver = function (Request $request, Model $model): mixed {
411416
$default = $this->getValue($model);
412417

413-
if (is_callable($this->aggregateResolver)) {
418+
if ($this->aggregated) {
414419
return (string) $default;
415420
}
416421

@@ -541,6 +546,8 @@ public function aggregate(string $fn = 'count', string $column = '*'): static
541546
$column === '*' ? '' : sprintf('_%s', $column)
542547
));
543548

549+
$this->aggregated = true;
550+
544551
return $query->withAggregate($this->getRelationName(), $column, $fn);
545552
};
546553

src/Root.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Root
2727
*
2828
* @var string
2929
*/
30-
public const string VERSION = '2.7.1';
30+
public const string VERSION = '2.7.2';
3131

3232
/**
3333
* The registered booting callbacks.

0 commit comments

Comments
 (0)