How do I join query string in pagination of laravel 4?
For example: I have a data listing and on this same screen I have a search filter. When I send a get to request the filter in the list by url
http://localhost/lista-de-produtos?marca=1
,
the data is listed as requested, but when I go to page 2 the paginate removes the parameter mark = 1 from the url and adds pag = 2, so the filter does not work.
Follow the query code:
$registros = Produtos::where(function ($query) {
if (Input::has('nome')) {
$nome = Input::get('nome');
$query->where('nome', 'LIKE', "%{$nome}%");
}
if (Input::has('marca')){
$marcaId = Input::get('marca');
$query->where('marca_id', '=', $marcaId);
}
})->paginate(20);