How do I see the name of a related field instead of id?
So many posts asking for the same, and so many responses to the same post....
You need to add the field to the relation. Ex:
public function delegation()
{
return $this->belongsTo('App\Delegacao', 'id');
}
or
public function userId()
{
return $this->belongsTo(User::class, 'id');
}
If your relation is
{
"relationship": {
"key": "id",
"label": "name",
"page_slug": "admin/users"
}
}
Will return the name of the user, and if you click it will go the the user details page
a little correction on the previous reply, because i was getting wrong relationship
public function userId()
{
return $this->belongsTo(User::class, 'foreign_key');
}
in the case of user it should be user_id
The above 2 comments are correct.
This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.
Most helpful comment
So many posts asking for the same, and so many responses to the same post....
You need to add the field to the relation. Ex:
or
If your relation is
Will return the name of the user, and if you click it will go the the user details page