1
votes

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

1
So it does't seem to be possible via the User:: model. But works with that solution, thanks.KiwiJuicer

1 Answers

1
votes

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);
});