Laravel

laravel count and fetch all data using join

Pinterest LinkedIn Tumblr
$teams = DB::table('teams')
                 ->select("teams.*","matches.result"
                ,DB::raw('matches.result, COALESCE(count(matches.result),0) as point'))
                 ->leftjoin("matches","matches.result","=","teams.teamName")
                 ->groupBy('matches.result')
                 ->get();

Write A Comment

Open chat
Hey Visitor,

How can I help you?