F
Filamentβ€’16mo ago
bellini

Display relationship data in a resource

I have a Post model that has a user_id column that relates to User model on a relationship called user(), in a resource how can I show the user name for that Post? Right now I have this, and looking at the docs I did not found a way to do this:
->columns([
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('email'),
Tables\Columns\TextColumn::make('created_at')
->dateTime(),
Tables\Columns\TextColumn::make('updated_at')
->dateTime(),
Tables\Columns\TextColumn::make('user_id')
->columns([
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('email'),
Tables\Columns\TextColumn::make('created_at')
->dateTime(),
Tables\Columns\TextColumn::make('updated_at')
->dateTime(),
Tables\Columns\TextColumn::make('user_id')
Solution:
Tables\Columns\TextColumn::make('user.name')
Tables\Columns\TextColumn::make('user.name')
https://filamentphp.com/docs/3.x/tables/columns/relationships#displaying-data-from-relationships...
Jump to solution
2 Replies
Solution
Emil | Emien
Emil | Emienβ€’16mo ago
Tables\Columns\TextColumn::make('user.name')
Tables\Columns\TextColumn::make('user.name')
https://filamentphp.com/docs/3.x/tables/columns/relationships#displaying-data-from-relationships
bellini
belliniOPβ€’16mo ago
I was lookin in the panel builder docs for some reason, thank you πŸ™‚
Want results from more Discord servers?
Add your server