6 months ago

Paginate error on second page (The page isn’t redirecting properly)

Posted 6 months ago by haroncorreia

Hello friends!

I'm trying to paginate some records. There's my code:

Declared route:

Route::any('estados/search', '[email protected]')->name('estados.search');

In the Estado model, i've declared a function for search:

public function search($filter = null)
    # code...

    $rs = $this->where(function($query)use($filter){
        if ($filter){
            $query->where('nome', 'LIKE', '%' . $filter . '%');
    return $rs;


So I call the search function in the Controller, and call the view:

public function search(Request $request) {

    $filters = $request->except('_token');

    $estados = $this->repository->search($request->filter);

    return view('paginas.admin.estados.index', [
        'estados' => $estados,
        'filters' => $filters


In the blade view, i paginate like this:

@if (isset($filters)) {!! $estados->appends($filters)->links() !!} @else {!! $estados->links() !!} @endif

The code writed runs OK! First page goes well, but second page and nexts ones returns a "Problem loading page - The page isn’t redirecting properly" on Firefox. I've searched solutions but no ones solved this. Can anyone help me.


Please sign in or create an account to participate in this conversation.