Example #1
0
 /**
  * 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.');
     }
 }
Example #2
0
File: Step2.php Project: ninetor/23
 /**
  * @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();
     }
 }
Example #3
0
File: Step3.php Project: ninetor/23
 /**
  * @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();
     }
 }