Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Laraveldeep's avatar

Try this

{{ $admins->appends(Request::except('page'))->links() }}

If you have query string on URL, you need to include those without page parameter. I suspect the reason it stays on page 1 is page=1 is included on your query string (since you have appended all) .

munazzil's avatar

@jlrdw

I think that you haven't go through with question which he has post first go and check the question,after that all I have tried it on my laravel 5.6 it's works fine.

and @jarrodestepp

can use as like below and check

{{$admins}}
Snapey's avatar

Please check the example posted guys and stop making bizarre suggestions.

1 like
jarrodestepp's avatar

Removing namespace did not change a thing. I am starting to think its a routing issue inside laravel or something.

jlrdw's avatar

Original stackoverflow query

public function index()
    {
        $admins = Admin::latest()->paginate(1);
        return view('admin.settings.admins.index', compact('admins'));
    }

There are no parameters being passed.

Op,

dd ($admins);

do you get anything at all if not your query is messed up, are you sending a parameter, This has nothing to do with pagination you have messed up somewhere check your routes etc.

Work some examples from the documentation download some free code on github.

debug do a stack Trace

Snapey's avatar

@jlrdw please check out all the postings. Getting results is not an issue. The paginator says there are three pages of results. The links are created. Only page 1 is returned irrespective of the page= query parameter

Snapey's avatar

I'm lost where you are with this now.

Just try adding a single route at the top of web.php

Route::get('/admins/admins', 'AdminsController@index');

and then php artisan route:clear

jarrodestepp's avatar

@SNAPEY - I will try that out, but i hav figured out that the pagination only works on the Route::get('/'); (Home page only)

jlrdw's avatar

Try something besides that latest thing write a regular query.

Using where and the conditions.

In 5.7 I have zero trouble with pagination.

Are you guys sure it's not something wrong or an error with latest.

jarrodestepp's avatar

Can you show me one of your route files and how you structure you controllers inside Http? I need help learning how to set this up since you guys said that I was doing it in a weird way.

jlrdw's avatar

Show all your code, controllers, views, models, etc. Here, not an image.

This post is so long, perhaps start a new post.

jarrodestepp's avatar

@JLRDW - Do you place your controllers in subfolders for the different users or keep them all in the one directory when using 5.7?

Snapey's avatar

There is nothing wrong with the samples you posted. Only your routes look suspect.

jlrdw's avatar

Do you place your controllers in subfolders for the different users or keep them all in the one directory when using 5.7?

No, in one app as examle I have a method:

  • index for users
  • indexAdmin for admins
  • indexAcct for bookkeeper

But all in same controller. Example routes:

Route::get('dog/index', 'DogController@index');
Route::get('dog/indexadmin', 'DogController@indexAdmin');

Route::any('admin/acct', 'AdminController@indexAcct');  // different controller

Just test this:

$admins = DB::table('admins')
                ->latest()
                ->paginate(1);
                 ///  then display view

Older, but read over:

https://github.com/laravel/ideas/issues/1001

Previous

Please or to participate in this conversation.