I am having one multi-select field. In my search.blade.php.
HTML::select2(
'test[]',
trans('file.test'),
trans("attr/file.test"),
Input::old('test[]'),
true)
and my scopeSearchFilter in model have following code.
if($request->has('test')) $query = $query->where('test',$request->get('test'));
I am not able to return array. It is returning nothing. Thanks in advance
In your code, you are defining the select as a array test[]
. But in your query, you are not accounting for multiple selections. You can either do:
$query = $query->whereIn('test', $request->get('test'));
Or update the query to use OR to search all terms selected in the input.