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


PHP Request::method方法代码示例

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


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

示例1: receive

 /**
  * Receive file upload
  * 
  * @param  Closure $handler
  * @return mixed
  */
 public function receive(Closure $callback = null)
 {
     if ($this->request->method() == 'GET') {
         return $this->checkChunk() ? response('Ok', 200) : response('No Content', 204);
     } else {
         return $this->receiveFile($callback);
     }
 }
开发者ID:inoplate,项目名称:media,代码行数:14,代码来源:Receiver.php

示例2: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->method() == 'POST' || $request->method() == 'DELETE') {
         return $next($request);
     }
     if ($request->method() == 'GET' || $this->tokensMatch($request)) {
         return $next($request);
     }
     throw new TokenMismatchException();
 }
开发者ID:njugunanduati,项目名称:androidlogin,代码行数:17,代码来源:VerifyCsrfToken.php

示例3: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     \Log::info($request->method());
     $hasPermission = true;
     $method = $request->method();
     if (strpos($request->path(), 'todo') !== false && ($method == 'PUT' || $method == 'DELETE')) {
         $id = $request->segment(2);
         $todo = Todo::find($id);
         $hasPermission = $todo ? Auth::user()->id == $todo->user_id : true;
     }
     return $hasPermission ? $next($request) : response('Unauthorized.', 401);
 }
开发者ID:nikdiklic,项目名称:laravel-angular-todo-list,代码行数:19,代码来源:CanPersistTodoData.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     //return parent::handle($request, $next);
     // Add this:
     if ($request->method() == 'POST' || $request->method() == 'PATCH' || $request->method() == 'PUT') {
         return $next($request);
     }
     //dd($request->method());
     if ($request->method() == 'GET' || $this->tokensMatch($request)) {
         return $next($request);
     }
     throw new TokenMismatchException();
 }
开发者ID:nutsdo,项目名称:mz-service,代码行数:20,代码来源:VerifyCsrfToken.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (extension_loaded('newrelic')) {
         newrelic_name_transaction(sprintf('%s (%s)', $request->getRequestUri(), $request->method()));
     }
     return $next($request);
 }
开发者ID:Nebo15,项目名称:gandalf.api,代码行数:14,代码来源:NewRelicMiddleware.php

示例6: getCurrentHash

 /**
  * Gets the view hash
  *
  * @return string
  */
 protected function getCurrentHash()
 {
     if ($this->currentHash === null) {
         $this->currentHash = md5($this->request->fullUrl() . $this->request->method() . $this->request->getClientIp());
     }
     return $this->currentHash;
 }
开发者ID:kenarkose,项目名称:tracker,代码行数:12,代码来源:Tracker.php

示例7: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->method() == 'POST' && $request->input('api_key') != getenv('API_KEY')) {
         return response()->json(\JsonHelper::getErrorResponse(\HttpResponse::HTTP_UNAUTHORIZED, 'API key is invalid.'), \HttpResponse::HTTP_UNAUTHORIZED);
     }
     return $next($request);
 }
开发者ID:peterwcm,项目名称:l5-app,代码行数:14,代码来源:VerifyApiKey.php

示例8: update

 /**
  * Update the specified resource in storage.
  * Se utiliza en postman x-www-form-urlencoded
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $fabricante = Fabricante::find($id);
     if (!$fabricante) {
         return response()->json(['data' => 'No se encuentra el fabricante con id ' . $id], 404);
     }
     $metodo = $request->method();
     $nombre = $request->input('nombre');
     $telefono = $request->input('telefono');
     $flag = false;
     if ($metodo == 'PATCH') {
         if ($nombre != null and $nombre != '') {
             $fabricante->nombre = $nombre;
             $flag = true;
         }
         if ($telefono != null and $telefono != '') {
             $fabricante->telefono = $telefono;
             $flag = true;
         }
         if ($flag) {
             $fabricante->save();
             return response()->json(['data' => 'Se ha actualizado el fabricante.'], 200);
         }
         return response()->json(['data' => 'No se modificó ningún fabricante.'], 304);
     }
     if (!$nombre or !$telefono) {
         return response()->json(['data' => 'Faltan campos para actualizar'], 422);
     }
     $fabricante->nombre = $nombre;
     $fabricante->telefono = $telefono;
     $fabricante->save();
     return response()->json(['data' => 'Se ha actualizado el fabricante.'], 200);
 }
开发者ID:zekinash,项目名称:RESTful-API,代码行数:40,代码来源:FabricanteController.php

示例9: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure $next
  * @param int $maxAttempts
  * @param int $decayTime in Minutes
  * @return mixed
  * @throws TooManyRequestsHttpException
  */
 public function handle($request, Closure $next, $maxAttempts = null, $decayTime = null)
 {
     // We only process, if throttle is generally enabled in the config.
     if (config('throttle.enable')) {
         // If no $maxAttempts was submitted, we use the default-value set in the config.
         if ($maxAttempts === null) {
             $maxAttempts = config('throttle.defaultMaxAttempts');
         }
         // If no $decayTime was submitted, we use the default-value set in the config.
         if ($decayTime === null) {
             $decayTime = config('throttle.defaultDecayTime');
         }
         // The key under which this request is handled.
         // It's a hashed string containing the client's IP, the URL-path and the HTTP-method.
         $key = sha1($request->ip() . $request->path() . $request->method());
         // Check, if maximum count of attempts have been reached.
         if (app(RateLimiter::class)->tooManyAttempts($key, $maxAttempts, $decayTime)) {
             // If they have been reached, throw an error including the time left till this resource is available again.
             $availableIn = app(RateLimiter::class)->availableIn($key);
             throw new TooManyRequestsHttpException($availableIn, 'Rate limit exceeded. Please wait ' . $availableIn . ' seconds before trying again.');
         } else {
             // If they have not been reached, we just count this hit.
             app(RateLimiter::class)->hit($key, $decayTime);
         }
     }
     return $next($request);
 }
开发者ID:nic-at,项目名称:throttle,代码行数:37,代码来源:ThrottleMiddleware.php

示例10: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $roleId = $this->user->getRoleId($this->auth->user()->id);
     $permitted_pages = $this->permitted_page->permittedPages($roleId);
     $is_page = false;
     foreach ($permitted_pages as $k => $page) {
         if (is_numeric($k)) {
             if ($request->is($page)) {
                 $is_page = true;
             }
         }
     }
     if (!$is_page) {
         if ($permitted_pages['access']) {
             return view('backend::_layouts.not_allowed');
         } else {
             if ($permitted_pages['process']) {
                 if ($request->method() != "GET") {
                     Flash::warning(trans('whole::http/middleware.permitted_page_warning'));
                     return redirect()->back();
                 }
             }
         }
     }
     return $next($request);
 }
开发者ID:phpspider,项目名称:core,代码行数:33,代码来源:PermittedPage.php

示例11: login

 public function login(Request $request)
 {
     if ('POST' == $request->method()) {
         return $this->attemptLogin($request);
     }
     return view('admin.login');
 }
开发者ID:bibekbhattaraibrt,项目名称:football,代码行数:7,代码来源:AuthController.php

示例12: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next, $aplicacion)
 {
     $metodo = $request->method();
     $user = JWTAuth::parseToken()->authenticate();
     switch ($metodo) {
         case 'GET':
             $tipo_permiso = 1;
             break;
         case 'POST':
             $tipo_permiso = 2;
             break;
         case 'PUT':
             $tipo_permiso = 2;
             break;
         case 'DELETE':
             $tipo_permiso = 2;
             break;
     }
     $privilegios = Privilegio::with('aplicacion')->where('user_id', $user->id)->where('aplicacion_id', $aplicacion);
     if ($tipo_permiso == 1) {
         $privilegios = $privilegios->where(function ($query) {
             $query->where('privilegios_tipo_id', 1)->orWhere('privilegios_tipo_id', 2);
         });
     } else {
         $privilegios = $privilegios->where('privilegios_tipo_id', $tipo_permiso);
     }
     $privilegios = $privilegios->first();
     if ($privilegios) {
         return $next($request);
     } else {
         return response('Unauthorized.', 401);
     }
 }
开发者ID:antoniopacheco,项目名称:CECINTRANET-API,代码行数:40,代码来源:PermisoAplicacion.php

示例13: handle

 /**
  * Handle an incoming request.
  *
  * Handle a GET verification request or a POST notification.
  *
  * @param  Illuminate\Http\Request $request
  * @return mixed
  */
 public function handle(Request $request)
 {
     if ($request->method() == 'GET') {
         return $this->verify();
     }
     return $this->handleTransaction($request);
 }
开发者ID:sebdesign,项目名称:laravel-viva-payments,代码行数:15,代码来源:WebhookController.php

示例14: checkRequest

 /**
  * Check the request headers.
  *
  * @param  Illuminate\Http\Request $request
  * @return void
  */
 protected function checkRequest(Request $request)
 {
     $this->checkAcceptHeader($request->header('accept'));
     if (!in_array($request->method(), ['GET', 'OPTIONS'])) {
         $this->checkContentTypeHeader($request->header('content-type'));
     }
 }
开发者ID:devdk,项目名称:signy,代码行数:13,代码来源:JsonApi.php

示例15: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $roleId = $this->user->getRoleId($this->auth->user()->id);
     $permitted_pages = $this->permitted_page->permittedPages($roleId);
     $is_page = false;
     foreach ($permitted_pages as $k => $page) {
         if (is_numeric($k)) {
             if ($request->is($page)) {
                 $is_page = true;
             }
         }
     }
     if (!$is_page) {
         if ($permitted_pages['access']) {
             return view('backend::_layouts.not_allowed');
         } else {
             if ($permitted_pages['process']) {
                 if ($request->method() != "GET") {
                     Flash::warning('Sayfa Erişim Seviyeniz Bu İşlemi Gerçekleştirmenizi Engelliyor');
                     return redirect()->back();
                 }
             }
         }
     }
     return $next($request);
 }
开发者ID:ringwoodinternet,项目名称:core,代码行数:33,代码来源:PermittedPage.php


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