File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,6 +39,27 @@ public function __construct(array $attributes = [])
3939 $ this ->connection = config ('tagging.connection ' );
4040 }
4141
42+ protected static function booted ()
43+ {
44+ static ::updating (function (Tag $ tag ) {
45+ $ oldSlug = $ tag ->getOriginal ('slug ' );
46+ $ newSlug = TaggingUtility::normalize ($ tag ->name );
47+
48+ if ($ oldSlug && $ oldSlug !== $ newSlug ) {
49+ $ taggedModel = TaggingUtility::taggedModelString ();
50+ $ taggedModel ::where ('tag_slug ' , $ oldSlug )->update ([
51+ 'tag_slug ' => $ newSlug ,
52+ 'tag_name ' => TaggingUtility::displayize ($ tag ->name ),
53+ ]);
54+ }
55+ });
56+
57+ static ::deleting (function (Tag $ tag ) {
58+ $ taggedModel = TaggingUtility::taggedModelString ();
59+ $ taggedModel ::where ('tag_slug ' , $ tag ->slug )->delete ();
60+ });
61+ }
62+
4263 /**
4364 * {@inheritDoc}
4465 */
You can’t perform that action at this time.
0 commit comments