$orders = Order::where('status','=',2)
->with(array(
'orderItems' => function($query) {
$query->whereNull('status');
}
))->leftjoin('users', function($join)
{
$join->on('orders.user_id', '=', 'users.id');
})
->get();
左結合を行うと、ユーザーの詳細を取得できますが、注文番号は User_ID(Order Table) になります。たとえば、->User_Id または ->Order_Id を取得しようとすると、同じになり、意味がありません。オーダー ID がユーザー ID のように重複しています。
ユーザー :: 注文が多い
これは左結合/結合でのみ発生します。これを修正する方法はありますか?