Shift with red gradient lettering

Use latest/oldest

Laravel

Convert your code to use the expressive latest and oldest methods instead of their respective orderBy sorting methods.

Before

Post::orderBy('published_at', 'DESC');
Comment::orderBy('created_at');
User::orderBy('status');

After

Post::latest('published_at');
Comment::oldest();
User::oldest('status');

← Back to the Workbench Tasks

Sign in with any of the following services to connect Shift with your Laravel project.


Don't use one of these services?

Temporarily push your project to a free, private repository on one of these cloud-based services or upgrade your project locally with Shift for Docker.