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


PHP Request::exists方法代码示例

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


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

示例1: getOAuth

 /**
  * Handle OAuth login.
  *
  * @param string $provider
  *
  * @return \Laravel\Lumen\Http\Redirector|\Illuminate\Http\RedirectResponse
  */
 public function getOAuth($provider)
 {
     switch ($provider) {
         case 'google':
         case 'facebook':
             if (!$this->request->exists('code')) {
                 return redirect('/login')->withErrors(trans('passwords.oauth_failed'));
             }
             break;
         case 'twitter':
             if (!$this->request->exists('oauth_token') || !$this->request->exists('oauth_verifier')) {
                 return redirect('/login')->withErrors(trans('passwords.oauth_failed'));
             }
             break;
     }
     /** @var SocialiteUser $userInfo */
     $userInfo = $this->socialite->driver($provider)->user();
     if ($this->registrar->loginViaOAuth($userInfo, $provider)) {
         return ['message' => 'Login successful'];
     }
     throw new LoginNotValidException(trans('passwords.oauth_failed'));
 }
开发者ID:AudithSoftworks,项目名称:Basis-API,代码行数:29,代码来源:AuthController.php

示例2: postAction

 public function postAction(Request $request)
 {
     if ($request->exists('btn-multiupload')) {
         echo '<pre>', print_r($request->file('file')), '</pre>';
         echo '<pre>', print_r($request->input()), '</pre>';
         $file = $request->file('file');
         $path = 'images/uploads';
         $filename = $file->getClientOriginalName();
         $file->move('images/uploads', $file->getClientOriginalName());
         $image = new Images();
         $image->image_name = $filename;
         $image->save();
         echo 'Uploaded';
     }
     if ($request->exists('btn-upload')) {
         $file = $request->file('uploader');
         $path = 'images/uploads';
         $filename = $file->getClientOriginalName();
         $file->move('images/uploads', $file->getClientOriginalName());
         $image = new Images();
         $image->image_name = $filename;
         $image->save();
         echo 'Uploaded';
     }
     //return redirect()->back();
 }
开发者ID:boodemon,项目名称:laravel-5,代码行数:26,代码来源:UploadController.php

示例3: updateBusStop

 public function updateBusStop($halteId, Request $request)
 {
     $busStopModel = new BusStop();
     $response = array();
     try {
         $response['code'] = 400;
         $response['data']['msg'] = 'noting updated, please check if your request is correct';
         if ($request->exists('nama_halte')) {
             $busStopModel->where('halte_id', '=', $halteId)->update(['nama_halte' => $request->input('nama_halte')]);
             $response['code'] = 200;
             $response['data']['msg'] = 'Nama halte has been updated';
         }
         if ($request->exists('alamat_halte')) {
             $busStopModel->where('halte_id', '=', $halteId)->update(['lokasi_halte' => $request->input('alamat_halte')]);
             $response['code'] = 200;
             $response['data']['msg'] = 'Lokasi halte has been updated';
         }
         if ($request->exists('latitude')) {
             $busStopModel->where('halte_id', '=', $halteId)->update(['latitude' => $request->input('latitude')]);
             $response['code'] = 200;
             $response['data']['msg'] = 'latitude halte has been updated';
         }
         if ($request->exists('longitude')) {
             $busStopModel->where('halte_id', '=', $halteId)->update(['longitude' => $request->input('longitude')]);
             $response['code'] = 200;
             $response['data']['msg'] = 'longitude halte has been updated';
         }
     } catch (\Exception $e) {
         $response['code'] = 500;
         $response['data']['msg'] = 'internal error, please try again later or contact administrator';
     }
     header("Access-Control-Allow-Origin: *");
     return response()->json($response);
 }
开发者ID:radityacandra,项目名称:passenger_information_system,代码行数:34,代码来源:BusStopController.php

示例4: handle

 /**
  * Run the request filter.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->exists('g-recaptcha-response')) {
         $recaptcha = new ReCaptcha(Settings::get('secret_key'));
         /**
          * Verify the reponse, pass user's IP address
          */
         $response = $recaptcha->verify($request->input('g-recaptcha-response'), $request->ip());
         /**
          * Fail, if the response isn't OK
          */
         if (!$response->isSuccess()) {
             if ($request->ajax()) {
                 throw new AjaxException($response->getErrorCodes());
             } else {
                 foreach ($response->getErrorCodes() as $code) {
                     Flash::error($code);
                 }
                 return redirect()->back()->withInput();
             }
         }
     }
     /**
      * Handle request
      */
     return $next($request);
 }
开发者ID:b0gok,项目名称:oc-captcha-plugin,代码行数:34,代码来源:CaptchaMiddleware.php

示例5: getParagraphCount

 /**
  * Returns the number of paragraphs to be generated by reading from the
  * value from the $_POST superglobal. If the value is not set or is set to
  * an invalid value it uses the default value.
  *
  * @param Request $request The request object posted by the user
  * @return int The number of paragraphs to be generated based on $_POST
  *             settings.
  */
 private function getParagraphCount($request)
 {
     if ($request->exists(self::PARAGRAPH_COUNT_KEY)) {
         return (int) $request->get(self::PARAGRAPH_COUNT_KEY);
     } else {
         return self::DEFAULT_PARAGRAPH_COUNT;
     }
 }
开发者ID:spitzgoby,项目名称:dwa15_p3,代码行数:17,代码来源:LipsumController.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $projectId = $request->exists('project_id') ? $request->get('project_id') : 0;
     if ($this->service->checkProjectPermissions($projectId) == false) {
         return ['error' => 'Access forbidden'];
     }
     return $this->service->addMember($request->all());
 }
开发者ID:felipeminello,项目名称:laravel.angular,代码行数:15,代码来源:ProjectMemberController.php

示例7: store

 public function store(Request $request, ImageUploader $uploader)
 {
     $file = $request->file('upload');
     $url = $uploader->upload($file);
     if ($request->exists('json')) {
         return ['uploaded' => 1, 'url' => $url];
     }
     return view('ckeditor::upload', ['url' => $url, 'funcNum' => (int) $request->input('CKEditorFuncNum')]);
 }
开发者ID:jeroennoten,项目名称:laravel-ckeditor,代码行数:9,代码来源:Images.php

示例8: index

 public function index(Request $request)
 {
     $stations = \App\Station::with('tags');
     if ($request->exists('tag_id')) {
         $stations = $stations->whereHas('tags', function ($q) use($request) {
             $q->whereRaw('`tags`.`id` = ' . $request->get('tag_id', 0));
         });
     }
     if ($request->user()->isAdmin()) {
         if ($request->exists('user_id')) {
             $stations = $stations->where('user_id', $request->get('user_id', 0));
         }
         $stations = $stations->get();
     } else {
         $stations = $stations->where('user_id', $request->user()->id)->get();
     }
     return view('backend.stations.index', compact('stations'));
 }
开发者ID:ZeljkoDzafic,项目名称:AeroMeter,代码行数:18,代码来源:StationsController.php

示例9: postAction

 public function postAction(Request $request)
 {
     $arr = $request->get('id');
     if ($request->exists('delete') && $arr) {
         foreach ($arr as $key => $id) {
             Users::where('id', $id)->delete();
         }
     }
     return redirect()->back();
 }
开发者ID:boodemon,项目名称:laravel-5,代码行数:10,代码来源:UserController.php

示例10: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Comment $comment, Request $request)
 {
     $validator = Validator::make($request->all(), ['published' => 'sometimes|date', 'title' => 'sometimes|max:255|min:3', 'content' => 'sometimes', 'group' => 'sometimes|integer', 'comments' => 'sometimes']);
     if ($validator->passes()) {
         // TBD check user has write access to group
         $comment = $comment->comment;
         $comment->title = $request->exists('title') ? $request->title : $comment->title;
         $comment->content = $request->exists('content') ? $request->content : $comment->content;
         $comment->allow_comments = $request->exists('comments') ? (bool) $request->comments : $comment->allow_comments;
         $comment->group_id = $request->exists('group') ? (bool) $request->group : $comment->group_id;
         $comment->save();
         if ($comment->save()) {
             return $this->respondWithItem($comment, new PostTransformer());
         } else {
             return $this->errorInternal('Unable to update comment');
         }
     } else {
         return $this->errorValidation($validator->messages);
     }
 }
开发者ID:jasonb8293,项目名称:fox-api,代码行数:26,代码来源:CommentController.php

示例11: saveAddress

 public function saveAddress(Request $request, \CodeCommerce\AddressUser $addressUser)
 {
     $userId = $request->get('user_id');
     if ($request->exists('delivery')) {
         $delivery = $request->get('delivery');
         $addressUser->create(['user_id' => $userId, 'type' => 'delivery', 'city' => $delivery['city'], 'address' => $delivery['address'], 'state' => $delivery['state'], 'country' => $delivery['country'], 'zipcode' => $delivery['zipcode']]);
     }
     if ($request->exists('billing')) {
         $billing = $request->get('billing');
         $addressUser->create(['user_id' => $userId, 'type' => 'billing', 'city' => $billing['city'], 'address' => $billing['address'], 'state' => $billing['state'], 'country' => $billing['country'], 'zipcode' => $delivery['zipcode']]);
     }
     switch ($request->get('redirect_to')) {
         case 'checkout':
             return redirect()->route('checkout.orderPlace');
             break;
         default:
             return redirect()->route('account');
             break;
     }
 }
开发者ID:eduardolcouto,项目名称:laravel-commerce,代码行数:20,代码来源:AccountController.php

示例12: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  *
  * @throws \Illuminate\Session\TokenMismatchException
  */
 public function handle($request, Closure $next)
 {
     if ('testing' === App::environment() && $request->exists('_token')) {
         $input = $request->all();
         $input['_token'] = $request->session()->token();
         $request->replace($input);
     }
     if ($this->isReading($request) || $this->shouldPassThrough($request) || $this->tokensMatch($request)) {
         return $this->addCookieToResponse($request, $next($request));
     }
     throw new TokenMismatchException();
 }
开发者ID:alnutile,项目名称:security_review,代码行数:21,代码来源:VerifyCsrfToken.php

示例13: tokenize

 public function tokenize(\Illuminate\Http\Request $request)
 {
     if (!$request->exists('code')) {
         return redirect("/");
     }
     $params = ['client_id' => env('VK_APP_ID'), 'client_secret' => env('VK_APP_KEY'), 'code' => $request->get('code'), 'redirect_uri' => env('VK_APP_REDIRECT')];
     $curl = new Curl(null, $params, [], "https://oauth.vk.com/access_token");
     $vkResponse = $curl->all();
     Session::put('vk_expires', $vkResponse->expires_in);
     Session::put('vk_token', $vkResponse->access_token);
     Session::put('vk_userid', $vkResponse->user_id);
     return redirect('/');
 }
开发者ID:pongo,项目名称:vk-adv,代码行数:13,代码来源:VkController.php

示例14: grid

 public function grid(Request $request)
 {
     if ($request->ajax() && $request->exists('req')) {
         $req = json_decode($request->get('req'));
         $perPage = $req->page->perPage;
         $from = $perPage * ($req->page->currentPage - 1);
         //--< to get users from company
         $query = User::distinct();
         if (!is_null($req->sort)) {
             foreach ($req->sort as $key => $value) {
                 $query->orderBy($key, $value);
             }
         }
         if (!is_null($req->filter)) {
             foreach ($req->filter as $key => $value) {
                 switch ($value->operator) {
                     case 'IsEqualTo':
                         $query->where($key, '=', $value->operand1);
                         break;
                     case 'IsNotEqualTo':
                         $query->where($key, '<>', $value->operand1);
                         break;
                     case 'StartWith':
                         $query->where($key, 'LIKE', $value->operand1 . '%');
                         break;
                     case 'Contains':
                         $query->where($key, 'LIKE', '%' . $value->operand1 . '%');
                         break;
                     case 'DoesNotContains':
                         $query->where($key, 'NOT LIKE', '%' . $value->operand1 . '%');
                         break;
                     case 'EndsWith':
                         $query->where($key, 'LIKE', '%' . $value->operand1);
                         break;
                     case 'Between':
                         $query->whereBetween($key, array($value->operand1, $value->operand2));
                         break;
                 }
             }
         }
         $total = $query->count();
         $query->take($perPage)->skip($from);
         $data = $query->get(['users.id as users.id', 'users.name as users.name', 'users.email as users.email', 'users.mobile as users.mobile', 'users.description as users.description', 'users.created_at as users.created_at', 'users.updated_at as users.updated_at']);
         $totalPage = ceil($total / $perPage);
         $countDataPerPage = count($data);
         $page = array("currentPage" => $req->page->currentPage, "lastPage" => $totalPage, "total" => $total, "from" => $from + 1, "count" => $countDataPerPage, "perPage" => $perPage);
         $result = ['data' => $data, 'page' => $page];
         //            dd($result);
         return json_encode($result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
     }
 }
开发者ID:mb-programmer,项目名称:startpoint,代码行数:51,代码来源:UsersController.php

示例15: grid

 public function grid(Request $request)
 {
     if ($request->ajax() && $request->exists('req')) {
         $req = json_decode($request->get('req'));
         $perPage = 10;
         $from = $perPage * ($req->page->currentPage - 1);
         $query = Newsletter::join('users', 'newsletters.user_id', '=', 'users.id')->select(['newsletters.id as newsletters.id', 'users.full_name', 'newsletters.title as newsletters.title', 'newsletters.content as newsletters.content', 'newsletters.receivers as newsletters.receivers', 'newsletters.created_at as newsletters.created_at']);
         if (!is_null($req->sort)) {
             foreach ($req->sort as $key => $value) {
                 $query->orderBy($key, $value);
             }
         }
         if (!is_null($req->filter)) {
             foreach ($req->filter as $key => $value) {
                 switch ($value->operator) {
                     case 'IsEqualTo':
                         $query->where($key, '=', $value->operand1);
                         break;
                     case 'IsNotEqualTo':
                         $query->where($key, '<>', $value->operand1);
                         break;
                     case 'StartWith':
                         $query->where($key, 'LIKE', $value->operand1 . '%');
                         break;
                     case 'Contains':
                         $query->where($key, 'LIKE', '%' . $value->operand1 . '%');
                         break;
                     case 'DoesNotContains':
                         $query->where($key, 'NOT LIKE', '%' . $value->operand1 . '%');
                         break;
                     case 'EndsWith':
                         $query->where($key, 'LIKE', '%' . $value->operand1);
                         break;
                     case 'Between':
                         $query->whereBetween($key, array($value->operand1, $value->operand2));
                         break;
                 }
             }
         }
         $total = $query->count();
         $query->take($perPage)->skip($from);
         $data = $query->get();
         $totalPage = ceil($total / $perPage);
         $countDataPerPage = count($data);
         $page = array("currentPage" => $req->page->currentPage, "lastPage" => $totalPage, "total" => $total, "from" => $from + 1, "count" => $countDataPerPage, "perPage" => $perPage);
         $result = ['data' => $data, 'page' => $page];
         return json_encode($result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
     }
 }
开发者ID:mb-programmer,项目名称:startpoint,代码行数:49,代码来源:NewslettersController.php


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