Пример #1
0
 /**
  * POST setting/feedback
  * return mixed
  */
 public function feedback()
 {
     if (!$this->validation->passes($this->validation->feedbackRules)) {
         return ApiResponse::validation($this->validation);
     }
     $account_id = Input::header('account_id');
     $content = Input::get('content');
     $contact = Input::get('contact');
     $version = Request::header('version');
     $versionCode = Request::header('build');
     $deviceId = Request::header('device_id');
     $channelId = Request::header('channel_id');
     $feedback = new Feedback();
     $feedback->account_id = $account_id;
     $feedback->content = $content;
     $feedback->version = $version . '-' . $versionCode;
     $feedback->version_code = $versionCode;
     $feedback->device_id = $deviceId;
     $feedback->channel_id = $channelId;
     if (!is_null($contact)) {
         $feedback->contact = $contact;
     }
     $result = $feedback->save();
     if ($result) {
         $message = config('quickcms.message_feedback_success');
         if (!empty($message)) {
             return ApiResponse::responseSuccessWithMessage($message);
         }
         return ApiResponse::responseSuccess();
     } else {
         return ApiResponse::responseFailure();
     }
 }
Пример #2
0
 /**
  * 手机号+验证码登陆方式
  * @return mixed
  * @throws \Exception
  */
 public function loginByCaptcha()
 {
     if (!$this->validation->passes($this->validation->loginByCaptchaRules)) {
         return ApiResponse::validation($this->validation);
     }
     $phone = Input::get('phone');
     $captcha = Input::get('captcha');
     // 验证码输入错误
     if (self::checkCaptcha($phone, $captcha)) {
         return ApiResponse::errorPreCondition(config('quickcms.message_captcha_error'));
     }
     // 验证帐号
     $account = $this->model->where('phone', $phone)->first();
     // token
     $token = self::generateToken();
     if (is_null($account)) {
         $account = new $this->model();
         $account->phone = $phone;
         $account->token = $token;
         $account->save();
     } else {
         // 黑名单
         if ($account->status != 0) {
             return ApiResponse::responseFailure(config('quickcms.code_black_account'), config('quickcms.message_black_account'));
         }
         $account->token = $token;
         $account->save();
     }
     return ApiResponse::responseSuccess($account);
 }