mardi 25 décembre 2018

Laravel Group Count

I want to ask how to implement Laravel Query with Multiple Group Count Result.

Basically it display the result of each voters in a barangay or town. However, aside from it I want to display the counts of voters if they are supporter or not labaled as 0 or 1 in their status.

public function brgy()
{
    $brgy = Voter::groupBy('brgy')           
            ->selectRaw('count(*) as total, brgy')
            ->get();
    return view('brgy', compact('brgy'));
}

Please help.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire