| Conditions | 3 | 
| Paths | 1 | 
| Total Lines | 9 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php | ||
| 13 | public static function bootAutoCreateUuid() | ||
| 14 |     { | ||
| 15 | // Auto populate uuid column on model creation | ||
| 16 |         static::creating(function ($model) { | ||
| 17 |             if(empty($model->{$model->getUuidColumn()}) || !Uuid::isValid($model->{$model->getUuidColumn()})) { | ||
| 18 |                 $model->{$model->getUuidColumn()} = Str::uuid()->toString(); | ||
| 19 | } | ||
| 20 | }); | ||
| 21 | } | ||
| 22 | |||
| 33 | 
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: