本文整理汇总了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);
}
}
示例2: checkRequestMethod
protected function checkRequestMethod()
{
if (!isset($this->config['methods'])) {
return true;
}
return in_array($this->request->getMethod(), $this->config['methods']);
}
示例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;
}
示例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;
}
示例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);
}
示例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)));
}
示例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();
}
示例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');
}
示例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');
}
示例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);
}
示例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);
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}