jeudi 8 mars 2018

loop through collection laravel with when()

I am creating a group stage tourney results page. I have converted wins to 3, l's 0, and tie's 1. The tie breaker (something I did not create) is the head-to-head records within the group. So I need a query that utilizes this variable:

        $grouphhomescores= PointData::selectRaw('team, sum((win)+(loss)+ 
   (tie)) as pointTotal')
   ->where('stage', 'group')
   ->where('stageSeries', 'H')
   ->where('ar', $id)->groupBy('team')
   ->orderBy('pointTotal', 'desc')
   ->distinct()->get();

But includes a when() (I believe) for when $grouphhomescores=$grouphhomescores that can somehow calculate the head v head record and determine which outcome yields the most points.

Aucun commentaire:

Enregistrer un commentaire