【发布时间】:2021-12-04 09:23:32
【问题描述】:
我有一个值数组,我想在查询模型时将其传递到 where 子句中
我如何做到这一点?
我有 $categorypro 变量以这种格式低于数组
Array
(
[0] => 4
[1] => 8
[1] => 5
)
目前我正在控制器中执行此操作,但未获得某些类别的正确数据
以下是我的控制器代码:
function filter_each_video(Request $request){
if(request()->ajax()){
if($request->has('categorypro') && ($request->get('categorypro')!= null)){
$categorypro = $request->get('categorypro');
$item = Item::whereIn('category_id', $categorypro)->get();
}
}
}
如果有人有更好的想法,请告诉我。或者这有什么问题,然后给出一些想法
【问题讨论】: