filamentphp/filament · error · InvalidArgumentException
Nested sorting only supports [BelongsTo], [HasOne], [MorphOn
Error message
Nested sorting only supports [BelongsTo], [HasOne], [MorphOne], [BelongsToThrough], and [HasOneThrough] relationships, [{class}] found. What it means
Error "Nested sorting only supports [BelongsTo], [HasOne], [MorphOne], [BelongsToThrough], and [HasOneThrough] relationships, [{class}] found." thrown in filamentphp/filament.
Source
Thrown at packages/support/src/Services/RelationshipOrderer.php:58
$relationship = Relation::noConstraints(fn () => $currentModel->{$relationshipSegment}());
$this->validateRelationshipType($relationship);
$chain[] = $relationship;
$currentModel = $relationship->getRelated();
}
return $chain;
}
protected function validateRelationshipType(Relation $relationship): void
{
if ($relationship instanceof BelongsTo || $relationship instanceof HasOne || $relationship instanceof MorphOne || $relationship instanceof BelongsToThrough || $relationship instanceof HasOneThrough) {
return;
}
throw new InvalidArgumentException(
'Nested sorting only supports [BelongsTo], [HasOne], [MorphOne], [BelongsToThrough], and [HasOneThrough] relationships, [' . $relationship::class . '] found.'
);
}
/**
* @param array<Relation> $relationshipChain
*/
protected function applyRelationshipConstraints(
EloquentBuilder $subquery,
array $relationshipChain,
Model $baseModel
): void {
$chainLength = count($relationshipChain);
for ($i = $chainLength - 1; $i >= 0; $i--) {
$isFirstRelationship = $i === 0;
$isSubqueryBase = $i === ($chainLength - 1);
View on GitHub (pinned to 53483fa934)
When it happens
Trigger: Thrown at packages/support/src/Services/RelationshipOrderer.php:58 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of filamentphp/filament@53483fa934 (2026-08-17).
Data as JSON: /api/errors/d51f6e4c0f0960bc.
Report an issue: GitHub.