Closed alexgarrettsmith closed 9 years ago
I was thinking people would/could just use the $model->tagged() function for this kind of scenario. But I can see the shortcut of using this.
@rtconner Yeah this is much more convenient. I was also considering extracting the following to another method to avoid duplication in both tagNames and tagSlugs, but I'll let you decide if you think this is better :)
$tagged = $this->tagged()->get(array('tag_slug'));
foreach($tagged as $tagged) {
$tagSlugs[] = $tagged->tag_slug;
}
return $tagSlugs;
I kept meaning to merge and then do upgrades. Apparently I haven't had time. So I'll just merge and do upgrades later.
Useful when checking for tags in a loop.
For example, I needed to use this in combination with Chosen (http://harvesthq.github.io/chosen/) to highlight tags selected on an article. Because tagNames gives a Str::title'd version as saved in the table, this can't be done cleanly.