I need to join four tables in Join using Laravel and i need to get count of the values from 2 tables along with the other two table datas.
Table Name: users / timesplayed / user_avatar / privatemessages
I need to get all values from users and user_avatar table and Count of rows from the other Two Tables.
I have used the following join Query but i am getting count Error on joining the privatemessages table.
Can u rectify what is wrong in this Join Query.
$user_id = Auth::user()->users_id;
return $user_information = DB::table('users')
->join('timesplayed','users.users_id','=','timesplayed.users_id')
->join('user_avatar','user_avatar.user_avatar_id','=','users.avatar')
->join('privatemessages','privatemessages.to_user_id','=','users.users_id')
->select('users.*',DB::raw('COUNT(timesplayed.users_id) as total'),'user_avatar.user_avatar_id',DB::raw('COUNT(privatemessage.privatemessage_id)'))
->where('privatemessages.status','=',1)
->where('users.users_id','=',$user_id)
->get();
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1SETAkz
via IFTTT
Aucun commentaire:
Enregistrer un commentaire