| Conditions | 5 |
| Paths | 1 |
| Total Lines | 25 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 30 |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | public function boot() |
||
| 21 | { |
||
| 22 | Model::maker(function (Model $model) { |
||
| 23 | $db = $this->app->db; |
||
| 24 | $model->setDb($db); |
||
| 25 | |||
| 26 | $isAutoWriteTimestamp = $model->getAutoWriteTimestamp(); |
||
| 27 | |||
| 28 | if (is_null($isAutoWriteTimestamp)) { |
||
| 29 | // 自动写入时间戳 |
||
| 30 | $model->isAutoWriteTimestamp($db->getConfig('auto_timestamp')); |
||
| 31 | } |
||
| 32 | |||
| 33 | $dateFormat = $model->getDateFormat(); |
||
| 34 | |||
| 35 | if (is_null($dateFormat)) { |
||
| 36 | // 设置时间戳格式 |
||
| 37 | $model->setDateFormat($db->getConfig('datetime_format')); |
||
| 38 | } |
||
| 39 | |||
| 40 | $connection = $model->getConnection(); |
||
| 41 | |||
| 42 | if (!empty($connection) && is_array($connection)) { |
||
| 43 | // 设置模型的数据库连接 |
||
| 44 | $model->setConnection(array_merge($db->getConfig(), $connection)); |
||
| 45 | } |
||
| 50 |