1 | <?php |
||
7 | class BlameableObserver |
||
8 | { |
||
9 | /** |
||
10 | * Listening to any creating events. |
||
11 | * |
||
12 | * @param \Illuminate\Database\Eloquent\Model $model |
||
13 | * |
||
14 | * @return void |
||
15 | */ |
||
16 | public function creating(Model $model) |
||
20 | |||
21 | /** |
||
22 | * Listening to any deleted events. |
||
23 | * |
||
24 | * @param \Illuminate\Database\Eloquent\Model $model |
||
25 | * |
||
26 | * @return void |
||
27 | */ |
||
28 | public function deleted(Model $model) |
||
29 | { |
||
30 | app(BlameableService::class)->setAttribute($model, 'deletedBy'); |
||
31 | |||
32 | if ($model->useSoftDeletes() && $model->isDirty()) { |
||
33 | $model->silentUpdate(); |
||
34 | } |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Listening to any restoring events. |
||
39 | * |
||
40 | * @param \Illuminate\Database\Eloquent\Model $model |
||
41 | * |
||
42 | * @return void |
||
43 | */ |
||
44 | public function restoring(Model $model) |
||
48 | |||
49 | /** |
||
50 | * Listening to any saving events. |
||
51 | * |
||
52 | * @param \Illuminate\Database\Eloquent\Model $model |
||
53 | * |
||
54 | * @return void |
||
55 | */ |
||
56 | public function saving(Model $model) |
||
60 | } |
||
61 |