© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago
Eric

How to share resource table to relation manager without modifying the query

SongResource
SongResource
:
i have a table

then, in
ArtistResource
ArtistResource
, i have a
SongsRelationManager
SongsRelationManager

(artist n n song)

so i found out that in the
SongsRelationManager
SongsRelationManager
i can do this:
public function table(Form $table): Form
{
    return SongResource::table($table);
}
public function table(Form $table): Form
{
    return SongResource::table($table);
}


but i see all the songs, not the artist's ones.

then, to solve it i modified the query:
public function table(Form $table): Form
{
    return SongResource::table($table)->query(Song::query()->whereHas('artists', fn ($q) => $q->where('artists.id', $this->ownerRecord->id)));
}
public function table(Form $table): Form
{
    return SongResource::table($table)->query(Song::query()->whereHas('artists', fn ($q) => $q->where('artists.id', $this->ownerRecord->id)));
}


so its done. but no! cuz songs have genres. in this case im assuming a song has only 1 genre and 1 genre has many songs. this being said, now i have an issue with the modified query. now i dont know if i have to search for artists relationship or if i have to search in the
genre_id
genre_id
field :/

what would u do?
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

How to update Relation Manager table data
FilamentFFilament / ❓┊help
15mo ago
How to properly use table relation, pivot table, and relation manager
FilamentFFilament / ❓┊help
15mo ago
Relation Manager Table Header
FilamentFFilament / ❓┊help
2mo ago
Table in Relation Manager
FilamentFFilament / ❓┊help
2y ago