rtconner / laravel-tagging

Tag support for Laravel Eloquent models - Taggable Trait
MIT License
882 stars 168 forks source link

Eager loading tags #26

Closed ortix closed 9 years ago

ortix commented 9 years ago

Is this possible? Because if I have a list of 1000 tagable entities, with each 10 tags, you can imagine that the amount of queuries become huge when getting them out of a forloop

rtconner commented 9 years ago

Yeah, just do something like

$articles = Article::with('tagged')->get();

...

foreach($article->tagged() as $tagged) {
    echo $tagged->tag_name;
}