php - Laravel 5 - DB join is returning just first table column set -
i have related mysql tables, , want obtain columns in of them, if try code manual, columns first table:
$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();
that columns 'users' table, not see contacts , orders columns.
try this
db::table('users')->join('contacts',function($join){$join->on('users.id','=','contacts.user_id')})->join('orders',function($join){$join->on('users.id','=','orders.user_id')})->get()
Comments
Post a Comment