How to check that inputted data is in foreach or n

2020-05-03 12:59发布

问题:

I have two rounds "first and knock-out". Only 4 teams can go to knock-out round, those who got the highest point on the first round. Now firstly, I want to select that 4 teams from first round and then check whether the inputted team is on the selected 4 teams or not. Take a look to my code(So far I tried). My problem is, if I input two team names from below dd($kos) it will save the $matches->round="first"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;
            }

         }
    }