Reputation: 515
I'v this in my controller after my query I paginate the itens to show in my view:
$format = Input::get('format', 'html');
$funcionario = Input::get('filter_funcionario');
$filter_funcionarios = $this->funcionario->lists('nome', 'cod');
//initialize query to DB
$horariosQuery = $this->horario->with(array('funcionario', 'item_contabil'))->orderby('cod', 'ASC');
if ($funcionario)
{
$horariosQuery->where('cod_funcionario', $funcionario);
}
$horariosQuery->where('validado', 0)
->orWhere('motivo', '<>', '')
->orderBy('data');
$horariosQuery->whereNull('deleted_at');
$horarios = $horariosQuery->paginate(40);
$data = array(
'horarios' => $horarios,
'filter_funcionarios' => (array( 0 =>'Selecione um funcionario') + $filter_funcionarios),
'funcionario' => $funcionario,
);
return View::make('horarios.inconsistencia', $data);
But when I aplly a filter and change the page, the page changes to number to but I loss my employee filter
How could I change the page but keep the filter in the page ? its possible do to somenthing like this using pagination? thx in advance!
answer :
that solved for me, get all inputs and append to the link
{{ $horarios->appends(Input::get())->links() }}
thx for the help!
Upvotes: 0
Views: 1833
Reputation: 81187
You need to append your filter to the pagination links like this:
{{ $horarios->appends('filter'=>'someValue')->links() }}
or if it is hash fragment of the url then:
{{ $horarios->fragment('someValue')->links() }}
Of course filter => someValue replace with your actual filter data.
Upvotes: 2