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

我的未来我决定 提交于 2020-01-30 11:54:06

问题


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;
            }

         }
    }

来源:https://stackoverflow.com/questions/55517650/how-to-check-that-inputted-data-is-in-foreach-or-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!