errors) ? current($model->errors)[0] : '数据异常!'; return [ 'code' => ApiCode::CODE_ERROR, 'msg' => $msg ]; } /** * ActiveRecord 数据验证,返回第一条错误验证 * @param array $model * @return string */ public function getErrorMsg($model = null) { if (!$model) { $model = $this; } $msg = isset($model->errors) ? current($model->errors)[0] : '数据异常!'; return $msg; } public function setSign($val) { $this->sign = $val; return $this; } }