count() Column Name Conflict on Laravel 4 Fluent Query Builder

1 Answers

The better way to do this is using 'as':

$users = DB::table('users')->join('user_roles','users.role_id','=','')->get(array('users.*', '** as user_roles_id**', 'user_roles.*'));
laravel db::query

I have a query like this:

$users = DB::table('users')->join('user_roles','users.role_id','=','')->get();

and a table that has a column id ( and another table that has columns id and user_id ( & user_roles.user_id),

but the problem is.. what is being returned on $user->id is the instead of the column.. how do i fix this so that what i get is not the role id but the user id instead..