jeudi 4 avril 2019

How to check that inputted data is in foreach or not?

I have two rounds "first and knock-out".Only the 4 team can go to knock-out round if they got the highest point on first round. Now firstly, I want to select that 4 team from first round and then check whether the inputted team is on the selected 4 team or not. Take a look to my code(So far i tried).Here i attach a dd($kos),if my inputted data is in the dd($kos) only then the $matches round="ko" else the $matches round="first"

$matches->round = "first";

$kos = DB::table("points")
    ->where("round", "=", "first")
    ->groupBy('team')
    ->orderByRaw('SUM(points) DESC')
    ->orderBy("run_rate", "DESC")
    ->limit(4)
    ->get();

 if(count($kos) > 0)
   {
    foreach($kos AS $ko){
     if($ko->team == $matches->team1 && $ko->team == $matches->team2) {
        $matches->round = "ko";
        break;
            }

         }
    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire