I am using below code to fetch records from database in Laravel
$products = new Product();
$products = $products->orderBy('id', 'DESC')->paginate(10);
But it's throwing exception
PDOException SQLSTATE[HY093]: Invalid parameter number
It's also showing below error:
Illuminate\Database\QueryException SQLSTATE[HY093]: Invalid parameter number (SQL: select count(*) as aggregate from 'tbl_products' where 'tbl_products'.'deleted_at' is null and 'category_id' = 10 and
created_at
between and ?)
I tried to find a solution which is already posted here but didn't work for me.
Before executing above code I've written code in a function and I think that code is affecting.
$timeframe = Input::get('daterange');
$products = $products->whereBetween('created_at', $timeframe);