Nov 5, 2022
0
Level 6
BelongsToMany with pivot and relation
I have a belongsTo relation which displays contacts via a pivot table. I have defined the model relations with ->using() and that works. The pivot table has extra fields which I can also display in Nova by using
->fields(function () { return [
Text::make('invite_id')
]});
which also works fine. My problem is now that the pivot table has a HasMany relation which I would like to show on the details page but the relation never shows.
->fields(function ($) {
return [
HasMany::make('UserMessages'),
Text::make('invite_id')
]})
Do relations work inside the fields() method of a belongsTo relation?
In Tinker I can query the data like this:
Card->contacts->first->pivot->messages
Thanks ...
Please or to participate in this conversation.