'int', 'options' => 'array', 'status' => 'int', 'is_tag_engine' => 'bool', 'created_at' => 'datetime', 'updated_at' => 'datetime', ]; public $timestamps = true; const CREATED_AT = 'created_at'; const UPDATED_AT = 'updated_at'; /** * 转换为配置格式(兼容原有的config格式) * * @return array */ public function toConfigArray(): array { $config = [ 'type' => $this->type, 'host' => $this->host, 'port' => $this->port, 'database' => $this->database, ]; if ($this->username) { $config['username'] = $this->username; } if ($this->password) { $config['password'] = $this->password; } if ($this->auth_source) { $config['auth_source'] = $this->auth_source; } if ($this->options) { $config['options'] = $this->options; } return $config; } }