I have create table where showing data. I also add few filters to filter data. Using paginate i show 20 records per page. After select filter and click search records in table filter with paginate in first page but as soon as i click next page filters getting reset. How to stop filters getting reset?
Below is my code,
public function index() {
$agos = DB::table('orders')
->leftJoin('companies', 'orders.company_id', '=', 'companies.id')
->select(DB::raw('orders.id, companies.name, orders.type, orders.data, orders.currency, orders.price, orders.status, DATE_FORMAT(orders.created_at,"%M %d, %Y") as created_at '))
->where('orders.merchant', '=', 'agos')
->where(function($query){
$status = Input::has('status') ? Input::get('status') : null;
$company = Input::has('company') ? Input::get('company') : null;
$from = Input::has('from_date') ? Input::get('from_date') : null;
$to = Input::has('to_date') ? Input::get('to_date') : null;
$from = date("Y-m-d", strtotime($from));
$to = date("Y-m-d", strtotime($to));
if(isset($status))
{
$query->where('orders.status', '=', $status);
}
if(isset($company))
{
$query->where('companies.name', '=', $company);
}
if(!empty($from) && !empty($to))
{
$query->whereBetween('orders.created_at', [$from, $to]);
}
})->orderBy('orders.created_at', 'desc')->paginate(20);
return $agos;
}
Can someone helps me?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire