| Total Complexity | 9 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 6 | trait HasDynamicColumn |
||
| 7 | { |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Boot the MariaDB Dynamic Column trait. |
||
| 11 | * |
||
| 12 | * @return void |
||
| 13 | */ |
||
| 14 | protected static function bootHasDynamicColumn() |
||
| 15 | { |
||
| 16 | static::addGlobalScope(new DynamicScope()); |
||
| 17 | static::saving( |
||
| 18 | function($model) { |
||
| 19 | foreach ($model->getCasts() as $column => $cast) { |
||
| 20 | if ($cast == 'Halalsoft\LaravelDynamicColumn\Dynamic' || $cast == "Halalsoft\LaravelDynamicColumn\DynamicObject") { |
||
| 21 | $model->$column = $model->$column; |
||
| 22 | } |
||
| 23 | } |
||
| 24 | } |
||
| 25 | ); |
||
| 26 | } |
||
| 27 | |||
| 28 | |||
| 29 | protected function newBaseQueryBuilder() |
||
| 36 | ); |
||
| 37 | } |
||
| 38 | |||
| 39 | |||
| 40 | public function getDynamicColumns() |
||
| 52 | } |