$user = User::join('orders', 'users.id', '=', 'orders.user_id') ->select('users.*', 'orders.price') ->get();
$products = DB::table('products') ->join('orders', 'products.id', '=', 'orders.product_id') ->join('customers', 'orders.customer_id', '=', 'customers.id') ->select('products.*', 'orders.*', 'customers.*') ->get();Here, we are joining the "products" table with the "orders" table by matching "product_id" in both tables. Then, we are joining the "orders" table with the "customers" table by matching "customer_id" in both tables. Then we are selecting all columns from all three tables. Package library: Illuminate/Database/Eloquent.