File tree Expand file tree Collapse file tree 6 files changed +26
-8
lines changed Expand file tree Collapse file tree 6 files changed +26
-8
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ Laravel Taggable Trait
77[ ![ Build Status] ( https://travis-ci.org/rtconner/laravel-tagging.svg?branch=laravel-7 )] ( https://travis-ci.org/rtconner/laravel-tagging )
88[ ![ Scrutinizer Code Quality] ( https://scrutinizer-ci.com/g/rtconner/laravel-tagging/badges/quality-score.png?b=laravel-7 )] ( https://scrutinizer-ci.com/g/rtconner/laravel-tagging/?branch=laravel-7 )
99
10+
11+
1012This package is not meant to handle javascript or html in any way. This package handles database storage and read/writes only.
1113
1214There are no real limits on what characters can be used in a tag. It uses a slug transform to determine if two tags are identical ("sugar-free" and "Sugar Free" would be treated as the same tag). Tag display names are run through Str::title()
Original file line number Diff line number Diff line change 2525
2626 // Delimiter used within tags
2727 'delimiter ' => '- ' ,
28-
29- // Model to use for the relation between tags and tagged records
28+
29+ 'tag_model ' => '\Conner\Tagging\Model\Tag ' ,
30+
3031 'tagged_model ' => '\Conner\Tagging\Model\Tagged ' ,
32+
33+ 'tag_group_model ' => '\Conner\Tagging\Model\TagGroup ' ,
3134];
Original file line number Diff line number Diff line change 33namespace Conner \Tagging \Console \Commands ;
44
55use Conner \Tagging \TaggingUtility ;
6- use Conner \Tagging \Model \TagGroup ;
76use Illuminate \Console \Command ;
87use Symfony \Component \Console \Input \InputArgument ;
98
@@ -19,7 +18,7 @@ public function handle()
1918 {
2019 $ groupName = $ this ->argument ('group ' );
2120
22- $ tagGroup = new TagGroup () ;
21+ $ tagGroup = new $ {TaggingUtility:: tagGroupModelString ()} ;
2322 $ tagGroup ->name = $ groupName ;
2423 $ tagGroup ->slug = TaggingUtility::normalize ($ groupName );
2524
Original file line number Diff line number Diff line change @@ -55,7 +55,9 @@ public function save(array $options = [])
5555 */
5656 public function setGroup (string $ group )
5757 {
58- $ tagGroup = TagGroup::query ()
58+ $ model = TaggingUtility::tagGroupModelString ();
59+
60+ $ tagGroup = $ model ::query ()
5961 ->where ('slug ' , TaggingUtility::normalize ($ group ))
6062 ->first ();
6163
@@ -100,7 +102,7 @@ public function isInGroup($groupName): bool
100102 */
101103 public function group ()
102104 {
103- return $ this ->belongsTo (TagGroup::class , 'tag_group_id ' );
105+ return $ this ->belongsTo (TaggingUtility:: tagGroupModelString () , 'tag_group_id ' );
104106 }
105107
106108 /**
Original file line number Diff line number Diff line change @@ -266,6 +266,14 @@ public static function tagModelString()
266266 */
267267 public static function taggedModelString ()
268268 {
269- return config ('tagging.tagged_model ' , 'Conner\Tagging\Model\Tagged ' );
269+ return config ('tagging.tagged_model ' , '\Conner\Tagging\Model\Tagged ' );
270+ }
271+
272+ /**
273+ * @return string
274+ */
275+ public static function tagGroupModelString ()
276+ {
277+ return config ('tagging.tag_group_model ' , '\Conner\Tagging\Model\TagGroup ' );
270278 }
271279}
Original file line number Diff line number Diff line change 44
55use Conner \Tagging \Model \Tag ;
66use Conner \Tagging \Model \TagGroup ;
7+ use Conner \Tagging \TaggingUtility ;
78
89class TagGroupBaseTest extends BaseTestCase
910{
@@ -91,7 +92,10 @@ private function createTagGroup($name = null): TagGroup
9192 if (is_null ($ name )) {
9293 $ name = $ this ->faker ->name ;
9394 }
94- return TagGroup::create ([
95+
96+ $ model = TaggingUtility::tagGroupModelString ();
97+
98+ return $ model ::create ([
9599 'name ' => $ name
96100 ]);
97101 }
You can’t perform that action at this time.
0 commit comments