© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•16mo ago•
1 reply
knous

Displaying data from BelongsToMany relationship in UserRelationManager

I'm having trouble displaying the Role title in a UserRelationManager table column. Here’s the setup I currently have: Model: Account.php

public function users()
{
return $this->belongsToMany(User::class, 'user_accounts', 'account_d', 'user_id', 'id', 'id')
->withPivot('id', 'role_id', 'email')
->withTimestamps();
} Model: User.php

public function accounts()
{
return $this->belongsToMany(Account::class, 'user_accounts', 'user_uuid', 'account_uuid', 'uuid', 'uuid')
->withPivot('id', 'role_id', 'email')
->withTimestamps();
} Model: UserAccount.php (Pivot Model)

public function user()
{
return $this->belongsTo(User::class, 'user_id', 'id');
}

public function account()
{
return $this->belongsTo(Account::class, 'account_id', 'id');
}

public function role()
{
return $this->belongsTo(Role::class, 'role_id', 'id');
} Displaying Columns in UserRelationManager

I’m trying to display both role_id and role.title in the table columns like this:

Tables\Columns\TextColumn::make('role_id')
->label('Role ID')
->sortable(),

Tables\Columns\TextColumn::make('role.title')
->label('Role Title')
->searchable()
->sortable(),

However, only the role_id displays correctly. role.title doesn’t show up as expected. Does anyone know why role.title isn’t displaying in the column, or how I might fix this? Any help would be appreciated!

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

Similar Threads

Recent Announcements

Similar Threads

Relationship belongstoMany
FilamentFFilament / ❓┊help
3y ago
BelongsToMany relationship in Repeater
FilamentFFilament / ❓┊help
3y ago
Scoping belongsToMany relationship?
FilamentFFilament / ❓┊help
3y ago
Displaying prefill data in action form select with relationship
FilamentFFilament / ❓┊help
16mo ago