20], [['mobile'], 'string', 'max' => 11], [['id_card'], 'string', 'max' => 18], [['allergy_history_details', 'sickness_detail'], 'string', 'max' => 100], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'user_id' => 'User ID', 'sex' => 'Sex', 'age' => 'Age', 'name' => 'Name', 'mobile' => 'Mobile', 'id_card' => 'Id Card', 'is_allergy_history' => 'Is Allergy History', 'allergy_history_details' => 'Allergy History Details', 'is_medical_history' => 'Is Medical History', 'sickness_detail' => 'Sickness Detail', 'liver_function_status' => 'Liver Function Status', 'kidney_function_status' => 'Kidney Function Status', 'pregnancy_breastfeeding_status' => 'Pregnancy Breastfeeding Status', 'status' => 'Status', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } /** * @param array $params * * @return bool|self */ public static function setData(array $params) { try { if (!empty($params['id'])) { $model = static::findOne(['id' => $params['id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]); if (!$model) { throw new RuntimeException('数据不存在或已删除'); } if ($model->mall_id != $params['mall_id']) { throw new RuntimeException('不允许操作此数据'); } if (!empty($params['user_id']) && $model->user_id != $params['user_id']) { throw new RuntimeException('不允许操作此数据'); } } else { $model = new static(); $model->loadDefaultValues(); } if (!$model->load($params, '')) { throw new RuntimeException($model->getErrorMessage()); } if (!$model->save()) { throw new RuntimeException($model->getErrorMessage()); } return $model; } catch (Exception $e) { static::$static_error = $e->getMessage(); return false; } } }