I have the following raw SQL query:
select a.id user_id, a.email_address, a.name_first, a.name_last, count(b.id) number_of_videos, sum(b.vimeo_duration) total_duration, sum(b.count_watched) total_playbacks from users a, videos b where a.id = b.tutor_id and a.email_address in ('candace_rennie@yahoo.com', 'tjm@hiltoncollege.com', 'matthewjameshenshall@gmail.com', 'nkululeko@syafunda.co.za', 'khulile@syafunda.co.za', 'nzakheni@syafunda.co.za') group by a.id;
This correctly gets 6 rows from the database. I'm trying to convert this to a Laravel database query like so:
$totals = DB::table('users') ->select(DB::Raw('users.id as user_id'), 'users.email_address', 'users.name_first', 'users.name_last', DB::Raw('count(videos.id) as number_of_videos'), DB::Raw('sum(videos.vimeo_duration) as total_duration'), DB::Raw('sum(videos.count_watched) as total_playbacks')) ->join('videos', 'users.id', '=', 'videos.tutor_id') ->where('users.id', 'videos.tutor_id') ->whereIn('users.email_address', array('candace_rennie@yahoo.com', 'tjm@hiltoncollege.com', 'matthewjameshenshall@gmail.com', 'nkululeko@syafunda.co.za', 'khulile@syafunda.co.za', 'nzakheni@syafunda.co.za')) ->groupBy('users.id') ->get();
This however return 0 rows. Is there anything I'm missing?