I want to get products of selected brands can be 1 or more (using checkbox) in laravel but it returns result of only one of my selected brands.
Form
<form action="{{route('mysearch')}}" method="post">
{{csrf_field()}}
<div class="filter-content">
<div class="checkbox">
@foreach($brands as $brand)
<label for="brands">
<input name="brands[]" type="checkbox" value="{{$brand->id}}">
{{$brand->title}}
</label>
@endforeach
</div>
</div>
<button type="submit" class="btn btn-danger">submit</button>
</form>
function
public function mysearch(Request $request) {
$brands = Brand::OfStatus('Active')->get();
$brand = Input::has('brands') ? Input::get('brands') : [];
$products = Product::where('brand_id', '=', $brand)->get();
return view('front.search', compact('products', 'brands'));
}
If I choose brands lenovo and lg I only get result of lenovo brand.