本文整理汇总了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);
}
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例11: login
public function login(Request $request)
{
if ('POST' == $request->method()) {
return $this->attemptLogin($request);
}
return view('admin.login');
}
示例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);
}
}
示例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);
}
示例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'));
}
}
示例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);
}