{"record":{"id":"bb76883d30a16652","repo":"filamentphp/filament","slug":"when-trying-to-guess-the-inverse-relationship-for","errorCode":null,"errorMessage":"When trying to guess the inverse relationship for column [{$this->getName()}], relationship [{$inverseNestedRelationshipName}] was not found on model [{$recordClass}]. Please define a custom [inverseRelationship()] for this column.","messagePattern":"When trying to guess the inverse relationship for column \\[(.+?)\\], relationship \\[(.+?)\\] was not found on model \\[(.+?)\\]\\. Please define a custom \\[inverseRelationship\\(\\)\\] for this column\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"packages/support/src/Concerns/HasCellState.php","lineNumber":476,"sourceCode":"            $record = $relationship->getRelated();\n\n            $inverseNestedRelationshipName = (string) str(class_basename($relationship->getParent()::class))\n                ->when(\n                    ($relationship instanceof BelongsTo ||\n                        $relationship instanceof BelongsToMany ||\n                        $relationship instanceof BelongsToThrough),\n                    fn (Stringable $name) => $name->plural(),\n                )\n                ->camel();\n\n            if ($record->hasAttribute($inverseNestedRelationshipName) || (! $record->isRelation($inverseNestedRelationshipName))) {\n                // The conventional relationship doesn't exist, but we can\n                // attempt to use the original relationship name instead.\n\n                if ($record->hasAttribute($namePart) || (! $record->isRelation($namePart))) {\n                    $recordClass = $record::class;\n\n                    throw new LogicException(\"When trying to guess the inverse relationship for column [{$this->getName()}], relationship [{$inverseNestedRelationshipName}] was not found on model [{$recordClass}]. Please define a custom [inverseRelationship()] for this column.\");\n                }\n\n                $inverseNestedRelationshipName = $namePart;\n            }\n\n            array_unshift($inverseRelationshipParts, $inverseNestedRelationshipName);\n        }\n\n        return $this->inverseRelationshipName = implode('.', $inverseRelationshipParts);\n    }\n\n    public function getRelationshipName(Model $record): ?string\n    {\n        $hasNestedMorphToRelationship = $this->hasNestedMorphToRelationship($record);\n\n        if (($this->relationshipNameCache !== null) && (! $hasNestedMorphToRelationship)) {\n            return $this->relationshipNameCache;\n        }","sourceCodeStart":458,"sourceCodeEnd":494,"githubUrl":"https://github.com/filamentphp/filament/blob/53483fa9340e4ec637985fe454ebb58afb92ea24/packages/support/src/Concerns/HasCellState.php#L458-L494","documentation":"Error \"When trying to guess the inverse relationship for column [{$this->getName()}], relationship [{$inverseNestedRelationshipName}] was not found on model [{$recordClass}]. Please define a custom [inverseRelationship()] for this column.\" thrown in filamentphp/filament.","triggerScenarios":"Thrown at packages/support/src/Concerns/HasCellState.php:476 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"53483fa9340e4ec637985fe454ebb58afb92ea24","analyzedAt":"2026-08-17T02:06:23.049Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}