use IlluminateSupportFacadesDB;
$users = DB::table('users')
->join('contacts', 'users.id', '=', 'contacts.user_id')
->join('orders', 'users.id', '=', 'orders.user_id')
->select('users.*', 'contacts.phone', 'orders.price')
->get();
$users = User::join('posts', 'posts.user_id', '=', 'users.id')
->where('users.status', 'active')
->where('posts.status','active')
->get(['users.*', 'posts.descrption']);
use IlluminateSupportFacadesDB;
//in the following example we will join two tables
//a products table and categories table
$categoryProducts = Product::join('categories', 'categories.id', '=', 'products.category_id')
->select('products.*', 'categories.category_name')
->where('products.status', 1)
->get();
$select->joinSub(
$selectSubQry,
'ag',
'ag.id',
'=',
'agp.userId'
);