假设我有这个 ids 数组 [3,4,5]
我从 Eloquent 中得到它...
$route = Route::where('station_id',$stations_id)
->pluck('id')->toArray();
所以,我想在 where 子句中使用这个数组从每条路线获取每个时间表,我这样做了:
$schedule = Schedule::select('id')
->where('route_id',$route)
->get();
问题是这只显示一条路线的时间表 ID。
最佳答案
使用whereIn
:
$schedule = Schedule::select('id')
->whereIn('route_id', $route)
->get();
关于php - 如何将数组传递给 laravel 中的 where 子句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57053179/