load($params['UserCard']); if (!$model->validate()) { return $model; } $card = UserCard::findOne(['id_user' => $userId]); if (!$card->save()) { $errors = $card->getErrors(); throw new BadRequestHttpException(array_shift($errors)[0]); } return ['status' => 'success']; } /** * @param array $params * @param int $userId * @return array|ChangeResumeForm * @throws BadRequestHttpException */ public function editText(array $params, int $userId): array|ChangeResumeForm { $model = new ChangeResumeForm(); $model->load($params); if (!$model->validate()) { return $model; } $card = UserCard::findOne(['id_user' => $userId]); $card->vc_text = $model->resume; if (!$card->save()) { $errors = $card->getErrors(); throw new BadRequestHttpException(array_shift($errors)[0]); } return ['status' => 'success']; } }