File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change 19
19
'taggable ' => [
20
20
'table_name ' => 'taggables ' ,
21
21
'morph_name ' => 'taggable ' ,
22
+
23
+ /*
24
+ * The fully qualified class name of the pivot model.
25
+ */
26
+ 'class_name ' => Illuminate \Database \Eloquent \Relations \MorphPivot::class,
22
27
]
23
28
];
Original file line number Diff line number Diff line change @@ -29,6 +29,11 @@ public function getTaggableTableName(): string
29
29
return config ('tags.taggable.table_name ' , 'taggables ' );
30
30
}
31
31
32
+ public function getPivotModelClassName (): string
33
+ {
34
+ return config ('tags.taggable.class_name ' );
35
+ }
36
+
32
37
public static function bootHasTags ()
33
38
{
34
39
static ::created (function (Model $ taggableModel ) {
@@ -52,6 +57,7 @@ public function tags(): MorphToMany
52
57
{
53
58
return $ this
54
59
->morphToMany (self ::getTagClassName (), $ this ->getTaggableMorphName ())
60
+ ->using ($ this ->getPivotModelClassName ())
55
61
->ordered ();
56
62
}
57
63
@@ -61,6 +67,7 @@ public function tagsTranslated(string | null $locale = null): MorphToMany
61
67
62
68
return $ this
63
69
->morphToMany (self ::getTagClassName (), $ this ->getTaggableMorphName ())
70
+ ->using ($ this ->getPivotModelClassName ())
64
71
->select ('* ' )
65
72
->selectRaw ("JSON_UNQUOTE(JSON_EXTRACT(name, '$. \"{$ locale }\"')) as name_translated " )
66
73
->selectRaw ("JSON_UNQUOTE(JSON_EXTRACT(slug, '$. \"{$ locale }\"')) as slug_translated " )
You can’t perform that action at this time.
0 commit comments