1

I have a simple pagination from my model User:

$users = User::paginate(15);

Unfortunately, it returns the results ordered by id or something. I want to order the results ASC first and then paginate on them.

Can't find any way to get that working in combination with the paginate() method, like:

$users = User::orderBy('username', 'asc')->paginate(15);

Any idea?

Thanks

KiwiJuicer
  • 1,952
  • 14
  • 28

1 Answers1

1

I already test it like your code. It works. Can you give the error.

Route::get('/view-tags', function()
{
    $tag = App\Tag::orderBy('name', 'asc')->paginate(5);
    dd($tag);
});
Faiz
  • 1,021
  • 9
  • 10