Skip to content

Commit

Permalink
Update README for proper eager loading
Browse files Browse the repository at this point in the history
From my experience with your package this is the only proper way to eager load. Otherwise the script would query the DB for every TAG I have. Test it yourself and let me know.
  • Loading branch information
Uibar committed Sep 11, 2015
1 parent 372e943 commit 357a546
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ class Article extends \Illuminate\Database\Eloquent\Model {
#### Quick Sample Usage

```php
$article = Article::with('tagged')->first(); // eager load
$article = Article::with(['tagged' => function($query) {
$query->with('tag');
}])
->first(); // eager load

foreach($article->tagged as $tagged) {
echo $tagged->tag_name . ' with url slug of ' . $tagged->tag_slug;
Expand Down

0 comments on commit 357a546

Please sign in to comment.