F
Filament11mo ago
Gudao

TextColumn displaying custom output

So in this project of mine, I want to store 3-5 user ids (foreign key) into an array and then possibly list the names attach to these ids into one column. In the filament demo page under the posts tab, there is a column of commented authors which lists several names but I know that is connected to another table in of it self. Is it possible to do it a simpler way or do I have to do what the demo did?
No description
No description
6 Replies
Gudao
GudaoOP11mo ago
I am aware of the repo and saw that it was related to another table under posts which is why I was wondering if there is a workaround for it without making a new model and resource as for this I dont know fully how to use it yet for an array pr at least to check 3 seperate columns
awcodes
awcodes11mo ago
TextColumn::make(‘users.name’)->listWithLineBreaks() Assuming you have a users relationship on the model.
Gudao
GudaoOP11mo ago
users relationship is just one I have 3 seperate relationships that need to be in one text column named users, secondUser, and thirdUser
awcodes
awcodes11mo ago
So, create a fake column.
TextColumn::make(‘custom_users’)
->getStateUsing(function($record) {
return $record->users->pluck(‘name’));
})
->listWithLineBreaks()
TextColumn::make(‘custom_users’)
->getStateUsing(function($record) {
return $record->users->pluck(‘name’));
})
->listWithLineBreaks()
Something like that.
Want results from more Discord servers?
Add your server