Skip to content

Commit

Permalink
Doc specification of columns in with method
Browse files Browse the repository at this point in the history
  • Loading branch information
carusogabriel authored Sep 14, 2017
1 parent 6d659aa commit 2441a98
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions eloquent-relationships.md
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,16 @@ In this example, Eloquent will only eager load posts where the post's `title` co
$query->orderBy('created_at', 'desc');
}])->get();

You may use [select](/docs/{{version}}/queries#selects) method to specify a custom select clause for the query:

$users = App\User::with(['posts' => function ($query) {
$query->select(['id', 'title']);
}])->get();

Or you may specify the columns to eager load directly in the `with` method:

$users = App\User::with('posts:id,title')->get();

<a name="lazy-eager-loading"></a>
### Lazy Eager Loading

Expand Down

0 comments on commit 2441a98

Please sign in to comment.