From 357a5462fb821feec32df1a993379af6f209b2e9 Mon Sep 17 00:00:00 2001 From: Uibar Ion-Cristian Date: Fri, 11 Sep 2015 03:00:31 +0300 Subject: [PATCH] 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. --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8db41fd..159ba40 100644 --- a/README.md +++ b/README.md @@ -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;