{"record":{"id":"557cb99b203c7247","repo":"filamentphp/filament","slug":"the-relationship-name-does-not-exist-on-the-m","errorCode":null,"errorMessage":"The relationship [{$name}] does not exist on the model [{$this->getModel()}].","messagePattern":"The relationship \\[(.+?)\\] does not exist on the model \\[(.+?)\\]\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"packages/forms/src/Components/CheckboxList.php","lineNumber":423,"sourceCode":"\n            return ($this->shouldTranslateLabel) ? __($label) : $label;\n        }\n\n        return parent::getLabel();\n    }\n\n    public function getRelationship(): ?BelongsToMany\n    {\n        $name = $this->getRelationshipName();\n\n        if (blank($name)) {\n            return null;\n        }\n\n        $record = $this->getModelInstance();\n\n        if ($record->hasAttribute($name) || (! $record->isRelation($name))) {\n            throw new LogicException(\"The relationship [{$name}] does not exist on the model [{$this->getModel()}].\");\n        }\n\n        return $record->{$name}();\n    }\n\n    public function getRelationshipName(): ?string\n    {\n        return $this->evaluate($this->relationship);\n    }\n\n    public function isBulkToggleable(): bool\n    {\n        return (bool) $this->evaluate($this->isBulkToggleable);\n    }\n\n    public function getEnumDefaultStateCast(): ?StateCast\n    {\n        $enum = $this->getEnum();","sourceCodeStart":405,"sourceCodeEnd":441,"githubUrl":"https://github.com/filamentphp/filament/blob/53483fa9340e4ec637985fe454ebb58afb92ea24/packages/forms/src/Components/CheckboxList.php#L405-L441","documentation":"When `->relationship($name)` is set on a CheckboxList, Filament resolves the relation by calling the method named `$name` on the field's model instance. Before calling it, `getRelationship()` verifies the name is not a plain column (`hasAttribute`) and is a recognized relation (`isRelation`); if either check fails it throws this LogicException, because `$record->{$name}()` would return a non-relation.","triggerScenarios":"`CheckboxList::make('tags')->relationship()` on a model with no `tags()` relation; `->relationship('category_id')` pointing at a foreign-key column instead of the relation method; a misspelled relationship name.","commonSituations":"The `belongsToMany` was never defined on the Eloquent model, the developer used the table column name rather than the relation name, or the field is attached to a plain/DTO-backed model that has no relations at all.","solutions":["Define the relation method on the model: `public function tags(): BelongsToMany { return $this->belongsToMany(Tag::class); }`.","Use the relationship method name (`relationship('tags')`), not the foreign key or pivot column.","If the options come from a static source, drop `->relationship()` and use `->options()` with `->live()`/save handling instead."],"exampleFix":"// before\nCheckboxList::make('technologies')\n    ->relationship('technology_ids'), // column, not a relation\n\n// after\nCheckboxList::make('technologies')\n    ->relationship('technologies'), // matches `technologies()` on the model","handlingStrategy":"validation","validationCode":"// Preflight before rendering a relationship-backed CheckboxList\n$modelInstance = $modelClass::newInstance();\n$relationshipName = 'technologies';\n\nif ($modelInstance->hasAttribute($relationshipName)\n    || (! $modelInstance->isRelation($relationshipName))) {\n    throw new InvalidArgumentException(\n        \"[{$relationshipName}] is not a relationship on [{$modelClass}].\"\n    );\n}","typeGuard":"function modelHasRelation(string|object $model, string $name): bool\n{\n    $instance = is_object($model) ? $model : new $model();\n\n    return (! $instance->hasAttribute($name)) && $instance->isRelation($name);\n}","tryCatchPattern":null,"preventionTips":["Use the Eloquent relation method name, never the foreign-key column, in ->relationship().","Add a schema lint that verifies every relationship() field against the model in CI.","Remember ->relationship() implies Eloquent persistence; for static option lists use ->options()."],"tags":["filament","forms","eloquent","relationships","checkbox-list"],"backgroundTag":"missing-eloquent-relationship","analyzedSha":"53483fa9340e4ec637985fe454ebb58afb92ea24","analyzedAt":"2026-08-17T02:06:23.049Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}