| Conditions | 3 |
| Paths | 1 |
| Total Lines | 19 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 6 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | public function boot() |
||
|
|
|||
| 24 | { |
||
| 25 | Model::maker(function (Model $model) { |
||
| 26 | $db = $this->app->db; |
||
| 27 | $config = $this->app->config; |
||
| 28 | $model->setDb($db); |
||
| 29 | |||
| 30 | $isAutoWriteTimestamp = $model->getAutoWriteTimestamp(); |
||
| 31 | |||
| 32 | if (is_null($isAutoWriteTimestamp)) { |
||
| 33 | // 自动写入时间戳 |
||
| 34 | $model->isAutoWriteTimestamp($config->get('database.auto_timestamp', 'timestamp')); |
||
| 35 | } |
||
| 36 | |||
| 37 | $dateFormat = $model->getDateFormat(); |
||
| 38 | |||
| 39 | if (is_null($dateFormat)) { |
||
| 40 | // 设置时间戳格式 |
||
| 41 | $model->setDateFormat($config->get('database.datetime_format', 'Y-m-d H:i:s')); |
||
| 42 | } |
||
| 47 |