TextColumn with nested relationships - How to display unique values?
Hi everyone! π
I'm working with a TextColumn that displays data from a nested relationship (MorphMany β BelongsToMany), and I need to show unique user names.
My setup:
-
P2pStaffProcessInstance has organizationalActivities() (MorphMany)
- P2pProcessActivity has users() (BelongsToMany)
Current code:
This displays all user names separated by commas, but the same user can appear multiple times if they're assigned to different activities.
What I need:
Display unique user names (no duplicates) in the column.
What I've tried:
But it still shows duplicate names. Any suggestions on the best way to handle this?
Thanks! πSolution:Jump to solution
fix with:
TextColumn::make('organizationalActivities.users.name')
->distinctList()
->searchable()
->sortable()...
1 Reply
Solution
fix with:
TextColumn::make('organizationalActivities.users.name')
->distinctList()
->searchable()
->sortable()