© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•12mo ago•
1 reply
flex

Pivot-Table with Morph-Relation?

Hello,

I have a Contract Model with a ContractResource and a Cluster Model with ClusterResoruce. Now I have a pivot table betweem them called cluster_contract with some normal attributs. Working just fine to attach them, edit pivot columns, etc. No problems here.

But now, the pivot table clust_contract, has again a morph relation to the model "County". So, I have a table clustercontractable with cluster_contract_id, _type, _id, columns, etc..

In the contract's relation for clusters() am doing a using() on a ClusterContract class extending the Pivot class. Doing this also to add casts to the pivot attributes, which also worked fine.

But if I now, add the counties() morphedBy relation to the ClusterContract class and add the

Forms\Components\Select::make('counties')
                ->label('Landkreise')
                ->multiple()
                ->preload()
                ->relationship('counties', 'name'),
Forms\Components\Select::make('counties')
                ->label('Landkreise')
                ->multiple()
                ->preload()
                ->relationship('counties', 'name'),


to the resource, I get the error Call to a member function getResults() on null
in vendor/filament/forms/src/Components/Select.php:889.

I made some debugging and the reason for this error is, that Filament tries to find the relation "counties" on the model "Cluster" and not on the pivot table "ClusterContract". Makes sense.

But... I also have fields in this resource like ::make('email'), etc.. and here Filament automatically detects, that I want to address the pivot's attribute email and not the Cluster attribute.

Is there a way to tell Filament, that with counties, I mean the relation on the ClusterContract table, and not on the Cluster table?

Thanks a lot!
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

RelationManager with relation having a morph
FilamentFFilament / ❓┊help
13mo ago
Relation Manager for pivot table
FilamentFFilament / ❓┊help
2y ago
HasMany Table Relationship pivot/group RelationManager
FilamentFFilament / ❓┊help
2y ago