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

zhigad's avatar

Display belongsTo relation in details of Nova resource

Does anyone have any experience with displaying belongsTo relationship details in separate panel?

For an example, we have an Order resource and in details page of it I would like to display fields from Customer (belongsTo) in separate panel. Currently I am using BelongsTo Field, but this generates only link to Customer resouce.

0 likes
5 replies
STEREOH's avatar

Yeah sorry, I didn't see the nova tag.

Never used it so I can't help you.

1 like
zhigad's avatar

@drflash If I remember correctly I solved it using callback. For an example:

Text::make('Relation', function () {
    return $this->resource->relation ? $this->resource->relation->relation_data : null;
})
``
2 likes
Bastian Schneider's avatar

You can do it by using the display-function to select what to display. See example below, you can also use this relation multiple times to display more than one field.

BelongsTo::make('MyRessource', 'myressource', 'App\Nova\myressource')->display(function ($myressource) { return $myressource->Field_to_display; }),

Please or to participate in this conversation.