Without testing I assume it could be something like this
$user = User::with(['orders', 'rates'])->whereId($userID)->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
my tables:
user --> normal table
orders -> with user_id,
rates -> with user_id, orders_id ;
In model Rate:
public function UserRate()
{
return $this->belongsTo('App\User');
}
public function GetOrder()
{
return $this->hasOne('App\Order');
}
}
In model user:
public function orders()
{
return $this->hasMany('App\Order');
}
public function offers()
{
return $this->hasMany('App\Offer');
}
public function rates()
{
return $this->hasMany('App\Rate');
}
Question: How to get order title(in order table) from RateController. Order title belong to specyfic order and user id.
I just one to have: order with user name(user table) and order title(from title table).
I try like this:
$user = User::findOrFail($id);
$rates = $user->rates->toArray();
$result = Rate::with($rates)->getOrder()->toArray();
but it fails.
Thx in advence. I love this forum.
Please or to participate in this conversation.