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


PHP Controller::response方法代码示例

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


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

示例1: getList

 /**
  * Ritorna la lista degli abbracci effettuati dall'utente.
  * Gestisce anche la paginazione automaticamente.
  *
  * @param Request $request
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function getList(Request $request)
 {
     $user = $this->getAuthenticatedUser();
     $hugs = Hug::where(function ($query) use($request) {
         /**
          * @var Builder $query
          */
         $query->whereNull('closed_at')->orWhere(function ($query) {
             /**
              * @var Builder $query
              */
             $query->whereNotNull('closed_at')->where('closed_at', '>=', Carbon::now()->subHours(24)->toDateTimeString());
             // Abbracci conclusi
         });
     })->where(function ($query) use($user) {
         /**
          * @var Builder $query
          */
         $query->where('user_seeker_id', '=', $user->id)->orWhere('user_sought_id', '=', $user->id);
     })->paginate(20);
     $response = json_decode($hugs->toJson());
     $response->list = $response->data;
     unset($response->data);
     return parent::response($response);
 }
开发者ID:Arthas91,项目名称:twohugs,代码行数:33,代码来源:HugsController.php

示例2: update

 public function update()
 {
     $user = $this->getAuthenticatedUser();
     /**
      * @var User $user
      */
     return parent::response(["user" => $user]);
 }
开发者ID:Arthas91,项目名称:twohugs,代码行数:8,代码来源:ProfileController.php

示例3: get

 public function get($id)
 {
     try {
         $user = User::findOrFail($id);
     } catch (\Exception $e) {
         return parent::response(['success' => false, 'error' => "User not found"]);
     }
     return $user;
 }
开发者ID:Arthas91,项目名称:twohugs,代码行数:9,代码来源:UserController.php

示例4: 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

示例5: getMonthVipList

 public function getMonthVipList(Request $request)
 {
     try {
         $this->validate($request, ['month' => 'required|integer|between:1,12', 'year' => 'required|integer|between:2016,3000']);
     } catch (ValidationException $e) {
         $errors = $e->getErrors();
         return parent::response(['validation' => false, 'errors' => $errors]);
     }
     //todo: da continuare
     $vipList = \DB::table('user_hug_feedbacks')->select('user_id', 'users.username', \DB::raw('sum(result) as feedback_result'))->join('hugs', 'user_hug_feedbacks.hug_id', '=', 'hugs.id')->join('users', 'users.id', '=', 'hugs.user_seeker_id')->whereMonth('hugs.created_at', "=", $request->get('month'))->whereYear('hugs.created_at', "=", $request->get('year'))->groupBy('user_id')->orderBy('feedback_result', 'desc')->limit(10)->get();
     return parent::response(["vipList" => $vipList]);
 }
开发者ID:Arthas91,项目名称:twohugs,代码行数:12,代码来源:VipController.php

示例6: 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

示例7: 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

示例8: 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

示例9: sendSelfies

 /**
  * Permette di caricare fino ad un massimo di 3 file
  *
  * @param Request $request
  * @param         $id
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function sendSelfies(Request $request, $id)
 {
     // TODO: Da terminare
     $user = $this->getAuthenticatedUser();
     /**
      * @var Hug $hug
      */
     $hug = Hug::whereId($id)->whereNull('closed_at')->where(function ($query) use($user) {
         /**
          * @var Builder $query
          */
         $query->where('user_seeker_id', '=', $user->id)->orWhere('user_sought_id', '=', $user->id);
     })->firstOrFail();
     $selfie = new UserHugSelfie();
     $selfie->file_name = 'test.jpg';
     $selfie->hug_id = $hug->id;
     $selfie->user_id = $user->id;
     $selfie->file_path = 'test/test2/test.jpg';
     $selfie->file_size = 99121;
     $selfie->save();
     return parent::response([]);
 }
开发者ID:Arthas91,项目名称:twohugs,代码行数:30,代码来源:HugController.php

示例10: userResponse

 /**
  * Gestisce le risposte degli utenti in seguito ad una richista di abbraccio.
  *
  * @param Request $request
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function userResponse(Request $request)
 {
     $responseType = last(explode('.', $request->route()->getName()));
     if (!in_array($responseType, ['accept', 'reject', 'noResponse'])) {
         // Risposta invalida
         abort(404, 'Invalid response');
     }
     try {
         $this->validate($request, ['id' => 'required|numeric|exists:searches,id']);
     } catch (ValidationException $e) {
         $errors = $e->getErrors();
         return parent::response([], $errors);
     }
     $user = $this->getAuthenticatedUser();
     /**
      * @var Search $search
      */
     $search = Search::whereId($request->input('id'))->whereNull('finished_at')->first();
     if ($user->id != $search->getLastFetchedUserId()) {
         // Non può rispondere a questa ricerca
         // TODO: Forse bisognerebbe prevedere qualcosa, soprattuto nell'accept. (oppure gestirlo nell'app?)
         abort(403);
     }
     switch ($responseType) {
         case 'accept':
             $this->userResponseAccept($search, $user);
             // Termino la ricerca
             $this->finish($search, self::FINISH_STATUS_SUCCESSFUL);
             // salvo alcuni dati utili
             $search->setFoundUserId($user->id);
             $search->save();
             // Notifico l'utente che ha avviato la ricerca
             $this->notifyTheSearcher($search);
             break;
         case 'reject':
             $this->userResponseReject($search, $user);
             // Continuo la ricerca
             $this->process($search);
             break;
         case 'noResponse':
             $this->userResponseNoResponse($search, $user);
             // Continuo la ricerca
             $this->process($search);
             break;
         default:
     }
     return parent::response([]);
 }
开发者ID:Arthas91,项目名称:twohugs,代码行数:55,代码来源:SearchController.php

示例11: 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

示例12: processLogin

 protected function processLogin(User $user, $token)
 {
     if (!empty($user->activation_code)) {
         return parent::response(['success' => false, 'error' => 'Your account is not active']);
     }
     if ($user->blocked) {
         return parent::response(['success' => false, 'error' => 'Your account is blocked']);
     }
     $user->last_login = Carbon::now();
     $user->save();
     return parent::response(['token' => $token]);
 }
开发者ID:Arthas91,项目名称:twohugs,代码行数:12,代码来源:AuthController.php


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