@@ -186,7 +186,10 @@ public function scopeWithAllTags(Builder $query, $tagNames): Builder
186
186
$ className = $ query ->getModel ()->getMorphClass ();
187
187
188
188
foreach ($ tagNames as $ tagSlug ) {
189
- $ tags = Tagged::query ()
189
+
190
+ $ model = TaggingUtility::taggedModelString ();
191
+
192
+ $ tags = $ model ::query ()
190
193
->where ('tag_slug ' , TaggingUtility::normalize ($ tagSlug ))
191
194
->where ('taggable_type ' , $ className )
192
195
->get ()
@@ -245,7 +248,9 @@ private function addTag($tagName)
245
248
$ previousCount = $ this ->tagged ()->where ('tag_slug ' , '= ' , $ tagSlug )->take (1 )->count ();
246
249
if ($ previousCount >= 1 ) { return ; }
247
250
248
- $ tagged = new Tagged ([
251
+ $ model = TaggingUtility::taggedModelString ();
252
+
253
+ $ tagged = new $ model ([
249
254
'tag_name ' => TaggingUtility::displayize ($ tagName ),
250
255
'tag_slug ' => $ tagSlug ,
251
256
]);
@@ -286,7 +291,9 @@ private function removeSingleTag($tagName)
286
291
*/
287
292
public static function existingTags (): Collection
288
293
{
289
- return Tagged::query ()
294
+ $ model = TaggingUtility::taggedModelString ();
295
+
296
+ return $ model ::query ()
290
297
->distinct ()
291
298
->join ('tagging_tags ' , 'tag_slug ' , '= ' , 'tagging_tags.slug ' )
292
299
->where ('taggable_type ' , '= ' , (new static )->getMorphClass ())
@@ -301,7 +308,9 @@ public static function existingTags(): Collection
301
308
*/
302
309
public static function existingTagsInGroups ($ groups ): Collection
303
310
{
304
- return Tagged::query ()
311
+ $ model = TaggingUtility::taggedModelString ();
312
+
313
+ return $ model ::query ()
305
314
->distinct ()
306
315
->join ('tagging_tags ' , 'tag_slug ' , '= ' , 'tagging_tags.slug ' )
307
316
->join ('tagging_tag_groups ' , 'tag_group_id ' , '= ' , 'tagging_tag_groups.id ' )
@@ -372,7 +381,9 @@ private function assembleTagsForScoping($query, $tagNames)
372
381
$ tagNames = array_map ($ normalizer , $ tagNames );
373
382
$ className = $ query ->getModel ()->getMorphClass ();
374
383
375
- $ tags = Tagged::query ()
384
+ $ model = TaggingUtility::taggedModelString ();
385
+
386
+ $ tags = $ model ::query ()
376
387
->whereIn ('tag_slug ' , $ tagNames )
377
388
->where ('taggable_type ' , $ className )
378
389
->get ()
0 commit comments