I think you can just use your relationship name here
BelongsTo::make('Organization', 'userOrganization', \App\Nova\Organization::class),
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
I have the following model relationhip:
Organization (has many) Users (have many) Queues.
In my Laravel models, I have:
app/Organization.php
class Organization extends Model
{
public function users()
{
return $this->hasMany('App\User');
}
...
app/User.php
class User extends Model
{
public function queues()
{
return $this->hasMany('App\Queue');
}
...
app/Queue.php
class Queue extends Model
{
public function user()
{
return $this->belongsTo('App\User');
}
public function userOrganization()
{
return $this->hasOneThrough(
'App\Organization',
'App\User',
);
}
...
What I want to do, if possible, is show the Organization on the Queue Index and Detail pages.
I can show the User on the Index/Detail, no problem, by adding this to the Nova Resource:
BelongsTo::make('User'),
But is it possible to reach through the relationship and get to the User's Organization and also display that on the Queue resource page?
Obviously, adding this to the Queue resource doesn't work: BelongsTo::make('Organization'),
Thanks in advance for taking a look.
Here's the solution, building on what @bobbybouwmann suggested above.
In app/Queue.php, I should have coded:
class Queue extends Model
{
public function user()
{
return $this->belongsTo('App\User');
}
public function userOrganization()
{
return $this->belongsTo('App\Organization', 'user_id');
}
...
Then in app\Nova\Queue.php
public function fields(Request $request)
{
return [
BelongsTo::make('Organization', 'userOrganization'),
...
Nova now lists Queues under their User's Organization.
Please or to participate in this conversation.