Laravel Model Eager loading and ordering

I'm new to Laravel and thought it would be great to buy Codehappy Dayle Rees.

I just finished a blog tutorial and thought a bit about how he got posts from the Post model. Based on the .net background (ASP.NET MVC), I think it will be important to order messages when trying to download the author.

He loads the model as follows.

$posts = Post::with('author')->get();

My question is where can you use the order_by clause? order_by itself works when I use:

$posts = Post::order_by('id', 'desc')->get();

Relations RAVEN

+5
source share
1 answer

I manage to solve this:

$posts = Post::with('author')->order_by('id', 'desc')->get();
+6
source

All Articles