

在我的费用表中有两个列,分别名为team和round。现在我想检查一下哪支球队打了两轮以上。然后,我想检索所有团队的名称。
$teams =Fee::has('round','>',2)->get();
foreach ($teams as $key => $team) {
$list[]=$team->team;
}
dd($list);发布于 2019-04-22 14:33:44
has()方法用于检查关系是否存在。在本例中,它正在寻找一个名为round的关系,但是,由于您没有这样的关系,它将抛出错误。
如果要为列添加约束,则只需使用where()
$teams = Fee::where('round', '>', 2)->get();
$list = [];
foreach ($teams as $key => $team) {
$list[] = $team->team;
}
dd($list);https://stackoverflow.com/questions/55790060
复制相似问题