This repository was archived by the owner on Aug 22, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +66
-3
lines changed
Expand file tree Collapse file tree 5 files changed +66
-3
lines changed Original file line number Diff line number Diff line change 55use Illuminate \Support \ServiceProvider ;
66use Mckenziearts \Shopper \Plugins \Catalogue \Models \Brand ;
77use Mckenziearts \Shopper \Plugins \Catalogue \Models \Category ;
8- use Mckenziearts \Shopper \Plugins \Catalogue \Observers \UserObserver ;
8+ use Mckenziearts \Shopper \Plugins \Catalogue \Observers \BrandObserver ;
99use Mckenziearts \Shopper \Plugins \Catalogue \Observers \CategoryObserver ;
1010
1111class ObserverServiceProvider extends ServiceProvider
@@ -17,7 +17,7 @@ class ObserverServiceProvider extends ServiceProvider
1717 */
1818 public function boot ()
1919 {
20- Brand::observe (UserObserver ::class);
20+ Brand::observe (BrandObserver ::class);
2121 Category::observe (CategoryObserver::class);
2222 }
2323}
Original file line number Diff line number Diff line change 44
55use Illuminate \Database \Eloquent \Model ;
66use Mckenziearts \Shopper \Models \Setting ;
7- use Mckenziearts \Shopper \Plugins \Catalogue \Models \Category ;
87use Mckenziearts \Shopper \Plugins \Catalogue \Models \Product ;
98use Mckenziearts \Shopper \Plugins \Users \Models \User ;
109
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Mckenziearts \Shopper \Plugins \Promo \Observers ;
4+
5+ use Mckenziearts \Shopper \Plugins \Promo \Models \Coupon ;
6+
7+ class CouponObserver
8+ {
9+ /**
10+ * Trigger before delete a Coupon
11+ *
12+ * @param Coupon $coupon
13+ */
14+ public function deleting (Coupon $ coupon )
15+ {
16+ $ coupon ->products ()->detach ();
17+ $ coupon ->users ()->detach ();
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Mckenziearts \Shopper \Plugins \Promo \Providers ;
4+
5+ use Illuminate \Support \ServiceProvider ;
6+ use Mckenziearts \Shopper \Plugins \Promo \Models \Coupon ;
7+ use Mckenziearts \Shopper \Plugins \Promo \Observers \CouponObserver ;
8+
9+ class ObserverServiceProvider extends ServiceProvider
10+ {
11+ /**
12+ * Bootstrap any application services.
13+ *
14+ * @return void
15+ */
16+ public function boot ()
17+ {
18+ Coupon::observe (CouponObserver::class);
19+ }
20+ }
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ public function boot()
1515 {
1616 $ this ->registerDatabase ();
1717 $ this ->registerMenu ();
18+ $ this ->registerProviders ();
1819
1920 $ this ->loadRoutesFrom (__DIR__ . '/../routes.php ' );
2021 $ this ->loadJsonTranslationsFrom (__DIR__ . '/../Resources/Lang ' );
@@ -49,4 +50,28 @@ public function register() : void
4950 {
5051
5152 }
53+
54+ /**
55+ * Register provider
56+ *
57+ * @return void
58+ */
59+ public function registerProviders () : void
60+ {
61+ foreach ($ this ->provides () as $ provide ) {
62+ $ this ->app ->register ($ provide );
63+ }
64+ }
65+
66+ /**
67+ * Register any package services.
68+ *
69+ * @return array
70+ */
71+ public function provides () : array
72+ {
73+ return [
74+ ObserverServiceProvider::class
75+ ];
76+ }
5277}
You can’t perform that action at this time.
0 commit comments