| Conditions | 5 |
| Paths | 1 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 25 | protected static function boot() |
||
| 26 | { |
||
| 27 | parent::boot(); |
||
| 28 | |||
| 29 | static::saving(function ($model) { |
||
| 30 | // Check if settings column exists before trying to save |
||
| 31 | try { |
||
| 32 | $columns = Schema::getColumnListing($model->getTable()); |
||
| 33 | if (!in_array('settings', $columns)) { |
||
| 34 | // Remove settings from attributes if no column |
||
| 35 | unset($model->attributes['settings']); |
||
| 36 | unset($model->original['settings']); |
||
| 37 | } elseif (empty($model->settings) || $model->settings === []) { |
||
| 38 | |||
| 39 | $model->settings = null; |
||
| 40 | } |
||
| 41 | } catch (\Exception $e) { |
||
| 42 | // If we cant check, just unset it to be safe |
||
| 43 | unset($model->attributes['settings']); |
||
| 44 | } |
||
| 58 |