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


PHP Request::getMethod方法代码示例

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


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

示例1: makeResponse

 protected function makeResponse(Request $request)
 {
     $message = $this->translator->get('c::auth.login-required');
     if ($request->ajax() || $request->isJson() || $request->wantsJson()) {
         return Response::json(['error' => $message], 403);
     } else {
         $url = $this->url->action('anlutro\\Core\\Web\\AuthController@login');
         $intended = $request->getMethod() == 'GET' ? $request->fullUrl() : ($request->header('referer') ?: '/');
         $this->session->put('url.intended', $intended);
         return $this->redirect->to($url)->with('error', $message);
     }
 }
开发者ID:anlutro,项目名称:l4-core,代码行数:12,代码来源:AuthFilter.php

示例2: checkRequestMethod

 protected function checkRequestMethod()
 {
     if (!isset($this->config['methods'])) {
         return true;
     }
     return in_array($this->request->getMethod(), $this->config['methods']);
 }
开发者ID:baopham,项目名称:laravel-api-mocker,代码行数:7,代码来源:ApiMockerController.php

示例3: createFromRequest

 /**
  * @param \Illuminate\Http\Request $request
  *
  * @return static
  */
 public static function createFromRequest(Request $request)
 {
     $instance = new static();
     if (in_array($request->getMethod(), ['POST', 'PATCH', 'PUT'])) {
         $instance->input = $request->json();
     } else {
         $instance->input = $request->query;
     }
     if ($request->query->has('per_page')) {
         $instance->perPage = intval($request->query->get('per_page'));
     }
     if ($request->query->has('page')) {
         $instance->page = intval($request->query->get('page'));
     }
     $instance->query = $request->query;
     $instance->apiClass = explode('@', $request->route()[1]['uses'])[0];
     $instance->method = $request->getMethod();
     $instance->headers = $request->headers;
     $instance->token = static::getToken($request);
     $instance->callback = $request->query->get('callback');
     $params = $request->route()[2];
     if (isset($params['id'])) {
         $id = intval($params['id']);
         $instance->resourceId = $id > 0 ? $id : null;
     }
     return $instance;
 }
开发者ID:vampirekiss,项目名称:lumen-restful-starter-kit,代码行数:32,代码来源:RestfulRequest.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  LaravelRequest $request
  * @param  Closure $next
  *
  * @return mixed
  */
 public function handle(LaravelRequest $request, Closure $next)
 {
     $message = new Request($request->getMethod(), new Uri($request->getUri()), $request->headers->all(), $request->getContent());
     $result = $this->extractor->getRequest($message);
     $event = $this->logger->begin($result['request'], $request->getUri(), $request->getMethod(), '');
     $response = null;
     try {
         /** @var LaravelResponse $response */
         $response = $next($request);
     } catch (Exception $e) {
         $response = LaravelResponse::create($e->getMessage(), 500);
     } finally {
         $this->logResponse($response, $event);
     }
     return $response;
 }
开发者ID:rawphp,项目名称:laravel-communication-logger,代码行数:24,代码来源:CommunicationLog.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (in_array($request->getMethod(), self::PARSED_METHODS)) {
         $request->merge(json_decode($request->getContent()));
     }
     return $next($request);
 }
开发者ID:akuo95,项目名称:Project-Vlambeer,代码行数:15,代码来源:JsonMiddleware.php

示例6: run

 /**
  * @param Request $request
  */
 public function run(Request $request)
 {
     $isPost = $request->getMethod() === 'POST';
     $src = $request->all();
     $cmd = isset($src['cmd']) ? $src['cmd'] : '';
     $args = [];
     if (!function_exists('json_encode')) {
         $error = $this->elFinder->error(elFinder::ERROR_CONF, elFinder::ERROR_CONF_NO_JSON);
         $this->output(['error' => '{"error":["' . implode('","', $error) . '"]}', 'raw' => TRUE]);
     }
     if (!$this->elFinder->loaded()) {
         $this->output(['error' => $this->elFinder->error(elFinder::ERROR_CONF, elFinder::ERROR_CONF_NO_VOL), 'debug' => $this->elFinder->mountErrors]);
     }
     // telepat_mode: on
     if (!$cmd && $isPost) {
         $this->output(['error' => $this->elFinder->error(elFinder::ERROR_UPLOAD, elFinder::ERROR_UPLOAD_TOTAL_SIZE), 'header' => 'Content-Type: text/html']);
     }
     // telepat_mode: off
     if (!$this->elFinder->commandExists($cmd)) {
         $this->output(['error' => $this->elFinder->error(elFinder::ERROR_UNKNOWN_CMD)]);
     }
     // collect required arguments to exec command
     foreach ($this->elFinder->commandArgsList($cmd) as $name => $req) {
         $arg = $name == 'FILES' ? $_FILES : (isset($src[$name]) ? $src[$name] : '');
         if (!is_array($arg)) {
             $arg = trim($arg);
         }
         if ($req && (!isset($arg) || $arg === '')) {
             $this->output(['error' => $this->elFinder->error(elFinder::ERROR_INV_PARAMS, $cmd)]);
         }
         $args[$name] = $arg;
     }
     $args['debug'] = isset($src['debug']) ? !!$src['debug'] : FALSE;
     $this->output($this->elFinder->exec($cmd, $this->input_filter($args)));
 }
开发者ID:BlueCatTAT,项目名称:kodicms-laravel,代码行数:38,代码来源:Connector.php

示例7: __construct

 /**
  * Create the validator instance. 
  *
  * @param Illuminate\Http\Request 		$request
  * @param Illuminate\Validation\Factory $validation
  */
 public function __construct(Request $request, ValidationFactory $validation)
 {
     $this->request = $request;
     $this->validation = $validation;
     $this->setUpdating(in_array(strtolower($request->getMethod()), array('put', 'patch')));
     $this->defineInput();
 }
开发者ID:bigelephant,项目名称:input-validator,代码行数:13,代码来源:Validator.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->header('origin') !== 'https://sandbox.pagseguro.uol.com.br' && $request->getMethod() !== 'POST') {
         return response('Unauthorized.', 401);
     }
     return $next($request)->header('Access-Control-Allow-Origin', 'https://sandbox.pagseguro.uol.com.br')->header('Access-Control-Allow-Methods', 'POST');
 }
开发者ID:netoudi,项目名称:laravel,代码行数:14,代码来源:Cors.php

示例9: saveAction

 public function saveAction(Request $request)
 {
     $params = $request->all();
     unset($params['_token'], $params['q']);
     if (strlen($params['password'])) {
         $params['password'] = Crypt::encrypt($params['password']);
     }
     if ($request->getMethod() == 'POST') {
         // saving data!
         $isValid = $this->repository->validateRequest($request);
         if (!is_bool($isValid)) {
             $request->session()->flash('message', "Invalid data, please check the following errors: ");
             $request->session()->flash('validationErrros', $isValid);
             return redirect()->route('configuration')->withInput();
         }
         $configuration = $this->repository->findById($params['id']);
         if (!$configuration) {
             $request->session()->flash('message', "Configuration not found");
             return redirect('configuration');
         }
         $this->repository->update($params, $params['id']);
         $request->session()->flash('message', "Configuration updated successfully!");
         $request->session()->flash('success', true);
         return redirect('configuration');
     }
     $request->session()->flash('message', "Method not allowed");
     return redirect('configuration');
 }
开发者ID:rlacerda83,项目名称:task-control,代码行数:28,代码来源:ConfigurationController.php

示例10: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->getMethod() != 'GET' && $this->isReadOnlyModeEnabled()) {
         throw new HttpException(503);
     }
     return $next($request);
 }
开发者ID:vegax87,项目名称:Strimoid,代码行数:15,代码来源:CheckForReadOnlyMode.php

示例11: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->getMethod() == "OPTIONS") {
         $headers = array('Access-Control-Allow-Methods' => 'POST, GET, OPTIONS, PUT, DELETE', 'Access-Control-Allow-Headers' => 'X-Requested-With, content-type');
         return Response::make('', 200, $headers);
     }
     return $next($request);
 }
开发者ID:andra49,项目名称:kakas-visualisasi,代码行数:15,代码来源:CORSSetup.php

示例12: convert

 /**
  * Convert Request and Exception to array
  * @param Request $request
  * @param $e
  */
 public function convert(Request $request, $e)
 {
     $this->_data['stacktrace'] = ['line' => $e->getLine(), 'file' => $e->getFile(), 'message' => $e->getMessage(), 'code' => $this->getCode($e->getFile(), $e->getLine(), 10)];
     $this->_data['headers'] = $request->headers->all();
     $this->_data['cookies'] = $request->cookies->all();
     $this->_data['method'] = $request->getMethod();
     $this->_data['uri'] = $request->getRequestUri();
     $this->_data['params'] = $request->all();
 }
开发者ID:pixcero,项目名称:bugs,代码行数:14,代码来源:Report.php

示例13: rules

 /**
  * @param HttpRequest $request
  *
  * @return array
  */
 public function rules(HttpRequest $request) : array
 {
     if ($request->getMethod() === HttpRequest::METHOD_POST) {
         return self::RULES;
     }
     $rules = self::RULES;
     $rules['colour'][2] .= ",{$request->get('id')}";
     return $rules;
 }
开发者ID:hughgrigg,项目名称:ching-shop,代码行数:14,代码来源:PersistOfferRequest.php

示例14: handle

 /**
  * Log all api requests
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  *
  * @return mixed
  */
 public function handle(Request $request, \Closure $next)
 {
     try {
         $this->debug($request->getMethod() . ' ' . $request->getPathInfo());
     } catch (\Exception $_ex) {
         //  Ignored.
     }
     return parent::handle($request, $next);
 }
开发者ID:rajeshpillai,项目名称:dfe-common,代码行数:17,代码来源:ApiLogger.php

示例15: handle

 public function handle(Request $request, \Closure $next)
 {
     if ($request->getMethod() === "POST") {
         if ($this->validSignature($request) || $this->validShopId($request)) {
             return $next($request);
         }
     }
     $this->logger->hooksError($request->getContent(), $request);
     return new Response("", Response::HTTP_FORBIDDEN);
 }
开发者ID:ROBINHQ-COM,项目名称:Connect-Server,代码行数:10,代码来源:WebhookMiddleware.php


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