| @@ 44-51 (lines=8) @@ | ||
| 41 | * |
|
| 42 | * @param Model $model |
|
| 43 | */ |
|
| 44 | public function updating(Model $model) |
|
| 45 | { |
|
| 46 | $updatedBy = $model->getUpdatedByColumn(); |
|
| 47 | ||
| 48 | if (! $model->isDirty($updatedBy)) { |
|
| 49 | $model->$updatedBy = $this->getAuthenticatedUserId(); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * Set updatedBy column on save if value is not the same. |
|
| @@ 58-66 (lines=9) @@ | ||
| 55 | * |
|
| 56 | * @param \Illuminate\Database\Eloquent\Model $model |
|
| 57 | */ |
|
| 58 | public function saved(Model $model) |
|
| 59 | { |
|
| 60 | $updatedBy = $model->getUpdatedByColumn(); |
|
| 61 | ||
| 62 | if ($model->$updatedBy <> $this->getAuthenticatedUserId()) { |
|
| 63 | $model->$updatedBy = $this->getAuthenticatedUserId(); |
|
| 64 | $model->save(); |
|
| 65 | } |
|
| 66 | } |
|
| 67 | } |
|
| 68 | ||