I need to grab rows of
user
item
$users = DB::table('users')
->join('orders', 'orders.user_id', '=', 'users.id')
->join('items', 'items.user_id', '=', 'users.id');
user
item
You don't have to add an extra condition. The query will return results ONLY for the users you have orders and items related with. If you want to return only the users that have items related with, you can drop the join
with the orders
table (even though I have no idea why you would have user_id
in the items
table instead of in the orders
table).
$users = DB::table('users')->join('items', 'items.user_id', '=', 'users.id');