/** * Finds the Gift model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Gift the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Gift::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return bool */ public function checkIdentity() { if ($this->validate()) { $gift = Gift::findOne(['id' => intval($this->id)]); if ($this->validation_code == $gift->validation_code) { $gift->success = 1; $gift->save(); return true; } else { $gift->addError('validation_code', 'Код подтверждения неверен'); return $gift->getErrors(); } } else { return $this->getErrors(); } }
/** * @return bool */ public function addPhoneTo() { if ($this->validate()) { $gift = Gift::findOne(['id' => intval($this->id)]); $gift->setAttributes($this->getAttributes()); $gift->sendGiftResult(); if ($gift->success && $gift->send_success) { $gift->save(); return true; } else { $gift->addError('to', 'Информация отправлена в SMS на ваш номер телефона'); return $gift->getErrors(); } } else { return $this->getErrors(); } }