66use Illuminate \Support \Facades \Auth ;
77use NextDeveloper \Commons \Exceptions \NotAllowedException ;
88use NextDeveloper \IAM \Helpers \UserHelper ;
9+ use NextDeveloper \Events \Services \Events ;
910
1011/**
1112 * Class TestsObserver
@@ -35,6 +36,8 @@ public function creating(Model $model)
3536 !UserHelper::can ('create ' , $ model ),
3637 new NotAllowedException ('You are not allowed to create this record ' )
3738 );
39+
40+ Events::fire ('creating:NextDeveloper\Support\Tests ' , $ model );
3841 }
3942
4043 /**
@@ -44,6 +47,7 @@ public function creating(Model $model)
4447 */
4548 public function created (Model $ model )
4649 {
50+ Events::fire ('created:NextDeveloper\Support\Tests ' , $ model );
4751 }
4852
4953 /**
@@ -54,9 +58,11 @@ public function created(Model $model)
5458 public function saving (Model $ model )
5559 {
5660 throw_if (
57- !UserHelper::can ('update ' , $ model ),
61+ !UserHelper::can ('save ' , $ model ),
5862 new NotAllowedException ('You are not allowed to save this record ' )
5963 );
64+
65+ Events::fire ('saving:NextDeveloper\Support\Tests ' , $ model );
6066 }
6167
6268 /**
@@ -66,6 +72,7 @@ public function saving(Model $model)
6672 */
6773 public function saved (Model $ model )
6874 {
75+ Events::fire ('saved:NextDeveloper\Support\Tests ' , $ model );
6976 }
7077
7178
@@ -78,6 +85,8 @@ public function updating(Model $model)
7885 !UserHelper::can ('update ' , $ model ),
7986 new NotAllowedException ('You are not allowed to update this record ' )
8087 );
88+
89+ Events::fire ('updating:NextDeveloper\Support\Tests ' , $ model );
8190 }
8291
8392 /**
@@ -87,6 +96,7 @@ public function updating(Model $model)
8796 */
8897 public function updated (Model $ model )
8998 {
99+ Events::fire ('updated:NextDeveloper\Support\Tests ' , $ model );
90100 }
91101
92102
@@ -99,6 +109,8 @@ public function deleting(Model $model)
99109 !UserHelper::can ('delete ' , $ model ),
100110 new NotAllowedException ('You are not allowed to delete this record ' )
101111 );
112+
113+ Events::fire ('deleting:NextDeveloper\Support\Tests ' , $ model );
102114 }
103115
104116 /**
@@ -108,6 +120,7 @@ public function deleting(Model $model)
108120 */
109121 public function deleted (Model $ model )
110122 {
123+ Events::fire ('deleted:NextDeveloper\Support\Tests ' , $ model );
111124 }
112125
113126 /**
@@ -121,6 +134,8 @@ public function restoring(Model $model)
121134 !UserHelper::can ('restore ' , $ model ),
122135 new NotAllowedException ('You are not allowed to restore this record ' )
123136 );
137+
138+ Events::fire ('restoring:NextDeveloper\Support\Tests ' , $ model );
124139 }
125140
126141 /**
@@ -130,6 +145,7 @@ public function restoring(Model $model)
130145 */
131146 public function restored (Model $ model )
132147 {
148+ Events::fire ('restored:NextDeveloper\Support\Tests ' , $ model );
133149 }
134150 // EDIT AFTER HERE - WARNING: ABOVE THIS LINE MAY BE REGENERATED AND YOU MAY LOSE CODE
135151}
0 commit comments