Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Como converter a consulta mySQL para o Laravel 5.4 Query Builder

DB::table('feeds')
    ->selectRaw('*, count(comments.comment_id) as comment_count')
    ->join('users', 'users.id', '=', 'feeds.user_id')
    ->join('comments', 'feeds.id', '=', 'comments.comment_feed_id')
    ->groupBy('comments.comment_feed_id')
    ->get();