File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -292,6 +292,23 @@ public static function existingTags()
292292 ->orderBy ('tag_slug ' , 'ASC ' )
293293 ->get (array ('tag_slug as slug ' , 'tag_name as name ' , 'tagging_tags.count as count ' ));
294294 }
295+
296+ /**
297+ * Return an array of all of the tags that are in use by this model
298+ * @param $groups Array with groups names
299+ * @return Collection
300+ */
301+ public static function existingTagsInGroups (Array $ groups )
302+ {
303+ return Tagged::distinct ()
304+ ->join ('tagging_tags ' , 'tag_slug ' , '= ' , 'tagging_tags.slug ' )
305+ ->join ('tagging_tag_groups ' , 'tag_group_id ' , '= ' , 'tagging_tag_groups.id ' )
306+ ->where ('taggable_type ' , '= ' , (new static )->getMorphClass ())
307+ ->whereIn ('tagging_tag_groups.name ' ,$ groups )
308+ ->orderBy ('tag_slug ' , 'ASC ' )
309+ ->get (array ('tag_slug as slug ' , 'tag_name as name ' , 'tagging_tags.count as count ' ));
310+ }
311+
295312
296313 /**
297314 * Should untag on delete
You can’t perform that action at this time.
0 commit comments