I've been trying to do this mysql equivalent in laravel:
SELECT * FROM toys WHERE type_id In (1,2,3)
here is my Controller code:
public function index(Request $request)
{
$type = (new Type)->newQuery();
if($request->has('type_id')){
$type->whereIn('type_id',$request->type_id));
}
return $type->paginate(10);
}
The idea is to be able to query data from db in URL: localhost/toyslist?type_id=1,2,3
Been getting Invalid argument supplied foreach()
Any help is much appreciated!