Skip to content

Commit 357a546

Browse files
committed
Update README for proper eager loading
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.
1 parent 372e943 commit 357a546

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ class Article extends \Illuminate\Database\Eloquent\Model {
4545
#### Quick Sample Usage
4646

4747
```php
48-
$article = Article::with('tagged')->first(); // eager load
48+
$article = Article::with(['tagged' => function($query) {
49+
$query->with('tag');
50+
}])
51+
->first(); // eager load
4952

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

0 commit comments

Comments
 (0)