Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

k1r1l's avatar
Level 1

Display specific values ​​in relation

Good day! There is the essence of the game in which first_team_id and second_team_id are stored. When the player first_team_id or second_team_id is added to the game resource, all players will be displayed. And I need to display only those players whose id matches first_team_id and second_team_id.

BelongsToMany::make('First team', 'first_team_players', Player::class)->display('name') displays only the name of the player, how can I display both the name and surname

0 likes
2 replies
psylogic's avatar

You question is not clear, please always provide your code, or example !

kevinbui's avatar
kevinbui
Best Answer
Level 41

I think you are talking about Nova. I check the Laravel Nova docs and it seems that you can override the title() function to customise the display.

public function title()
{
    return “{$this->name} {$this->surname}”;
}
1 like

Please or to participate in this conversation.