This repository was archived by the owner on Mar 13, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +138
-0
lines changed
Expand file tree Collapse file tree 4 files changed +138
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace App \Observers ;
4+
5+ use App \Models \Package ;
6+
7+ class PackageObserver
8+ {
9+ /**
10+ * Handle to the package "creating" event.
11+ *
12+ * @param Package $package
13+ * @return void
14+ */
15+ public function creating (Package $ package )
16+ {
17+ $ package ->user_id = auth ()->user ()->id ;
18+ }
19+
20+ /**
21+ * Handle to the package "created" event.
22+ *
23+ * @param \App\Models\Package $package
24+ * @return void
25+ */
26+ public function created (Package $ package )
27+ {
28+ //
29+ }
30+
31+ /**
32+ * Handle the package "updated" event.
33+ *
34+ * @param \App\Models\Package $package
35+ * @return void
36+ */
37+ public function updated (Package $ package )
38+ {
39+ //
40+ }
41+
42+ /**
43+ * Handle the package "deleted" event.
44+ *
45+ * @param \App\Models\Package $package
46+ * @return void
47+ */
48+ public function deleted (Package $ package )
49+ {
50+ //
51+ }
52+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace App \Observers ;
4+
5+ use App \Models \Tutorial ;
6+
7+ class TutorialObserver
8+ {
9+ /**
10+ * Handle to the tutorial "creating" event.
11+ *
12+ * @param \App\Models\Tutorial $tutorial
13+ * @return void
14+ */
15+ public function creating (Tutorial $ tutorial )
16+ {
17+ $ tutorial ->user_id = auth ()->user ()->id ;
18+ }
19+
20+ /**
21+ * Handle to the tutorial "created" event.
22+ *
23+ * @param \App\Models\Tutorial $tutorial
24+ * @return void
25+ */
26+ public function created (Tutorial $ tutorial )
27+ {
28+ //
29+ }
30+
31+ /**
32+ * Handle the tutorial "updated" event.
33+ *
34+ * @param \App\Models\Tutorial $tutorial
35+ * @return void
36+ */
37+ public function updated (Tutorial $ tutorial )
38+ {
39+ //
40+ }
41+
42+ /**
43+ * Handle the tutorial "deleted" event.
44+ *
45+ * @param \App\Models\Tutorial $tutorial
46+ * @return void
47+ */
48+ public function deleted (Tutorial $ tutorial )
49+ {
50+ //
51+ }
52+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace App \Providers ;
4+
5+ use App \Models \Package ;
6+ use App \Models \Tutorial ;
7+ use App \Observers \PackageObserver ;
8+ use App \Observers \TutorialObserver ;
9+ use Illuminate \Support \ServiceProvider ;
10+
11+ class ObserverServiceProvider extends ServiceProvider
12+ {
13+ /**
14+ * Bootstrap services.
15+ *
16+ * @return void
17+ */
18+ public function boot ()
19+ {
20+ Package::observe (PackageObserver::class);
21+ Tutorial::observe (TutorialObserver::class);
22+ }
23+
24+ /**
25+ * Register services.
26+ *
27+ * @return void
28+ */
29+ public function register ()
30+ {
31+ //
32+ }
33+ }
Original file line number Diff line number Diff line change 163163 App \Providers \EventServiceProvider::class,
164164 App \Providers \RouteServiceProvider::class,
165165 App \Providers \ComposerServiceProvider::class,
166+ App \Providers \ObserverServiceProvider::class,
166167
167168 ],
168169
You can’t perform that action at this time.
0 commit comments