当前位置: 首页>>代码示例>>PHP>>正文


PHP Controller::error方法代码示例

本文整理汇总了PHP中App\Http\Controllers\Controller::error方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::error方法的具体用法?PHP Controller::error怎么用?PHP Controller::error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App\Http\Controllers\Controller的用法示例。


在下文中一共展示了Controller::error方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * @param Request $request
  * @return mixed
  */
 public function store(Request $request)
 {
     $isUser = $this->isValid($request);
     if ($isUser === false) {
         return Controller::response(Controller::error(22), 401);
     }
     $request->session()->push('user', $isUser);
     return Controller::response($isUser, 200);
 }
开发者ID:blyp,项目名称:blyp.api,代码行数:13,代码来源:AuthController.php

示例2: store

 /**
  * @param Request $request
  * @return mixed
  */
 public function store(Request $request)
 {
     $validate = ['email' => 'required|email', 'password' => 'required'];
     $validator = Controller::validator($request, $validate);
     if ($validator !== true) {
         return Controller::response(Controller::error(38), 400);
     }
     $isValid = $this->isValid($request);
     if ($isValid !== true) {
         return Controller::response(Controller::error(21), 400);
     }
     if ($request->hasFile('upload')) {
         $file = $request->file('upload');
         $name = uniqid(rand(), true) . "." . $file->getClientOriginalExtension();
         $file->move('storage/', $name);
         $request['picture'] = url('/storage') . "/" . $name;
     }
     $response = $this->user->pushUser($request);
     return Controller::response($response, 200);
 }
开发者ID:blyp,项目名称:blyp.api,代码行数:24,代码来源:SignupController.php

示例3: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $user = JWTAuth::parseToken()->authenticate();
     if (!JWTAuth::parseToken()->authenticate()) {
         return Controller::response(Controller::error(13), 401);
     }
     if ($user->id != $id && !Controller::supreme($user->role)) {
         return Controller::response(Controller::error(13), 401);
     }
     $user = json_decode($this->user->pullUser($id));
     if (!empty($user) || !collect($user)->isEmpty()) {
         if ($user[0]->picture) {
             $picture = str_replace(url('/storage') . "/", "", $user[0]->picture);
             $target = public_path('storage/') . $picture;
             @chmod($target, 0777 & ~umask());
             File::delete($target);
         }
     }
     $response = $this->user->deletePicture($id);
     return Controller::response($response, 204);
 }
开发者ID:blyp,项目名称:blyp.api,代码行数:27,代码来源:UserPictureController.php

示例4: authenticate

 public function authenticate(Request $request)
 {
     $credentials = $request->only('email', 'password', 'fid');
     $token = null;
     try {
         if (!($token = JWTAuth::attempt($credentials))) {
             return Controller::response(Controller::error(13), 401);
         }
         if (!empty($request->input('fid'))) {
             $user = $this->user->authFacebook($request);
         }
         if (!empty($request->input('email'))) {
             $user = $this->user->authEmail($request);
         }
         $hash = compact('token');
         $user['token'] = $hash['token'];
         return Controller::response($user, 200);
     } catch (JWTException $e) {
         return Controller::response(Controller::error(14), 500);
     }
 }
开发者ID:blyp,项目名称:blyp.api,代码行数:21,代码来源:AuthenticateController.php

示例5: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $user = JWTAuth::parseToken()->authenticate();
     if (!Controller::supreme($user->role)) {
         return Controller::response(Controller::error(13), 401);
     }
     $response = $this->newsletter->deleteNewsletter($id);
     return Controller::response($response, 204);
 }
开发者ID:blyp,项目名称:blyp.api,代码行数:15,代码来源:NewsletterController.php


注:本文中的App\Http\Controllers\Controller::error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。