I have muliple filter selecte query builder . I am not getting how to add whereIn with vaiable . In $resolution I am getting below array.
Array
(
[0] => 4K
[1] => HD
)
In $fps I am getting below array.
(
[0] => 25/1
[1] => 10/1
)
So i want fetch related data of 4K and HD values
My code as below
function filter_each_video(Request $request){
if(request()->ajax()){
$where_str = "1 = ?";
// dd($req['resolution']);
$where_params = array(1);
if($request->has('resolution') && ($request->get('resolution')!= null)){
$resolution = $request->get('resolution');
$where_str .= "and format = '".$resolution."' ";
echo "<pre>";
}
elseif($request->has('fps') && ($request->get('fps')!= null)){
$fps = $request->get('fps');
$where_str .= " fps = '$fps' ";
// $item = Item::whereIn('fps', $fps)->get();
}
$item = Item::select('*')
->whereIn($where_str)
->orderByRaw(\DB::raw("FIELD(id, ".implode(",",$where_str).")"))
->get();
$formats = DB::table('items')->select('format')->distinct()->get();
$fps = DB::table('items')->select('fps')->distinct()->get();
$data['item_count'] = $item;
$data['item'] = $item;
$html = view('frontend.pages.videos_for_each_filter', compact('data','formats','fps'))->render();