/**
  * Finds the InvitationCode model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return InvitationCode the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = InvitationCode::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #2
0
 /**
  * 使用邀请码
  * @param $id
  * @param $uid
  * @return bool|string
  */
 public static function use_code($id, $uid)
 {
     $log = InvitationCode::findOne($id);
     if ($log) {
         $log->use_id = $uid;
         $log->status = InvitationCode::STATUS_USED;
         if ($log->save()) {
             return true;
         } else {
             return 'save error';
         }
     } else {
         return 'find error';
     }
 }