| Conditions | 3 |
| Paths | 1 |
| Total Lines | 26 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | protected static function bootLogsActivity() |
||
| 14 | { |
||
| 15 | collect(static::eventsToBeRecorded())->each(function ($eventName) { |
||
| 16 | |||
| 17 | return static::$eventName(function (Model $model) use ($eventName) { |
||
| 18 | |||
| 19 | $description = $model->getDescriptionForEvent($eventName); |
||
| 20 | |||
| 21 | if ($description == '') { |
||
| 22 | return; |
||
| 23 | } |
||
| 24 | |||
| 25 | $extraProperties = []; |
||
| 26 | |||
| 27 | if ($model->shouldLogChanges()) { |
||
| 28 | $extraProperties['changes'] = $model->getChangedValues(); |
||
| 29 | } |
||
| 30 | |||
| 31 | app(ActivityLogger::class) |
||
| 32 | ->performedOn($model) |
||
| 33 | ->withExtraProperties($extraProperties) |
||
| 34 | ->log($description); |
||
| 35 | }); |
||
| 36 | |||
| 37 | }); |
||
| 38 | } |
||
| 39 | |||
| 75 |
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: