I have a page where the title of all the news on the site is listed, and it has pagination.
I was asked to put a search field, to make it easier to search for a particular piece of news.
I was able to do this form and the controller implementation, but the problem is this: I type something to filter. It appears right, but when you go to another page (by pagination), you lose this filter.
Here's how I did it:
The Controller
public function noticias()
{
$texto=Input::get('texto');
$noticias_geral = Noticia::where('ativa','s')
->whereHas('unidades', function($q){
$q->where('not_noticia_unidade.id_unidade', 1);
})
->Where('texto','like','%'.$texto.'%')
->orderBy('id_noticias','DESC')
->paginate(15);
return view('pages_home.noticias')->with('noticias_geral',$noticias_geral);
}
The route:
Route::any('/noticias', 'NoticiasController@noticias');
HTML:
@foreach ($noticias_geral as $key=> $dados)
<div class="col-md-12">
<div class="linhas_noticia">
{{ $dados->data->format('d/m/Y') }} - <a href="{!! url('noticia/'.$dados->id_noticias)!!}">{{ $dados->titulo }}</a>
</div>
</div>
@endforeach
.....................
<div class="col-lg-12">
{!! $noticias_geral->links() !!}
</div>
What did I do wrong?