1 | <?php |
||
20 | trait BaseModelEventsTrait |
||
21 | { |
||
22 | /** |
||
23 | * @var BaseRepositoryEventsInterface |
||
24 | */ |
||
25 | public static $repository; |
||
26 | |||
27 | /** |
||
28 | * booted. observe the base model event with priority 99. |
||
29 | * |
||
30 | * @return mixed |
||
31 | */ |
||
32 | public static function bootBaseModelEventsTrait() |
||
39 | |||
40 | /** |
||
41 | * set the related RepositoryEventsInterface. |
||
42 | * |
||
43 | * @param BaseRepositoryEventsInterface $repository |
||
44 | */ |
||
45 | public function setRepository(BaseRepositoryEventsInterface $repository) |
||
49 | |||
50 | /** |
||
51 | * get the related RepositoryEventsInterface. |
||
52 | * |
||
53 | * @return BaseRepositoryEventsInterface |
||
54 | */ |
||
55 | public function getRepository() |
||
59 | |||
60 | /** |
||
61 | * Listen a creating model event. |
||
62 | * |
||
63 | * @return mixed the function result |
||
64 | */ |
||
65 | public function onCreating() |
||
81 | |||
82 | /** |
||
83 | * Listen a created model event. |
||
84 | * |
||
85 | * @return mixed the function result |
||
86 | */ |
||
87 | public function onCreated() |
||
94 | |||
95 | /** |
||
96 | * Listen a updating model event. |
||
97 | * |
||
98 | * @return mixed the function result |
||
99 | */ |
||
100 | public function onUpdating() |
||
107 | |||
108 | /** |
||
109 | * Listen a updated model event. |
||
110 | * |
||
111 | * @return mixed the function result |
||
112 | */ |
||
113 | public function onUpdated() |
||
120 | |||
121 | /** |
||
122 | * Listen a saving model event. |
||
123 | * |
||
124 | * @return mixed the function result |
||
125 | */ |
||
126 | public function onSaving() |
||
144 | |||
145 | /** |
||
146 | * Listen a saved model event. |
||
147 | * |
||
148 | * @return mixed the function result |
||
149 | */ |
||
150 | public function onSaved() |
||
157 | |||
158 | /** |
||
159 | * Listen a deleting model event. |
||
160 | * |
||
161 | * @return mixed the function result |
||
162 | */ |
||
163 | public function onDeleting() |
||
183 | |||
184 | /** |
||
185 | * Listen a deleted model event. |
||
186 | * |
||
187 | * @return mixed the function result |
||
188 | */ |
||
189 | public function onDeleted() |
||
196 | |||
197 | /** |
||
198 | * Listen a restoring model event. |
||
199 | * |
||
200 | * @return mixed the function result |
||
201 | */ |
||
202 | public function onRestoring() |
||
216 | |||
217 | /** |
||
218 | * Listen a restored model event. |
||
219 | * |
||
220 | * @return mixed the function result |
||
221 | */ |
||
222 | public function onRestored() |
||
229 | |||
230 | /** |
||
231 | * Has the model loaded the SoftDeletes trait. |
||
232 | * |
||
233 | * @return bool |
||
234 | */ |
||
235 | public static function usingSoftDeletes() |
||
245 | } |
||
246 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: