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

Groax's avatar
Level 1

MorphTo and then BelongsTo

I have a MorphTo relation and that works great! but in the relation i need to grab the country.

In Laravel it works.

$client = Fund::with('relations', 'relations.fundRelationTable', 'relations.fundRelationTable.country')->find(1018);

In Nova i tried this.

MorphTo::make(__('Type'),'fundRelationTable')->types([Client::class, Contact::class])->searchable(),

BelongsTo::make(__('Country'), 'fundRelationTable.country', Country::class),

Whats works but its not whats i need.

Text::make(__('Country'), function () {
    return $this->fundRelationTable->country->name;
}),

who can help me :D

0 likes
0 replies

Please or to participate in this conversation.