Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 拉维尔雄辩何处法_Php_Laravel_Laravel 5_Eloquent - Fatal编程技术网

Php 拉维尔雄辩何处法

Php 拉维尔雄辩何处法,php,laravel,laravel-5,eloquent,Php,Laravel,Laravel 5,Eloquent,我有一个课程表,我想这样查询: semesters = [5,3,7]; $class_id = 3; Course::where(['class_id' => $class_id, 'semester_id' => $semesters ])->get(); 其中,$semests必须是一个数组。所以我想得到课程集合,其中班级id为3,学期id为5,3,7。但是,它只获取$Serm数组的第一个索引的集合。如何获取$Serm数组的所有值的集合?使用其中 Course::w

我有一个课程表,我想这样查询:

semesters = [5,3,7];

$class_id = 3;

Course::where(['class_id' => $class_id, 'semester_id' => $semesters ])->get();

其中,
$semests
必须是一个数组。所以我想得到课程集合,其中班级id为3,学期id为5,3,7。但是,它只获取$Serm数组的第一个索引的集合。如何获取$Serm数组的所有值的集合?

使用
其中

Course::whereIn('semester_id', $semesters)->where('semester_id', $semesters)->get();

使用
where
课程::where('semmer\u id',$semmests)->where('class\u id',$class\u id)->get()
这正是我想要的。我在上面的评论中给出了确切的答案。