2
I have a page where is listed the title of all news site, and has pagination.
I was asked to put a field of research, to facilitate the search for a certain news.
I was able to make this form and implement the controller, but the problem is this: I type something to filter. It appears right, but when going to another page (by paging), it loses this filter.
Just like I did:
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');
the 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 I did wrong?
The field
texto
filter is sent by GET or POST?– Jéf Bueno