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


PHP Request::replace方法代码示例

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


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

示例1: call

 /**
  * @param $uri
  * @param $method
  * @param array $parameters
  * @param bool $collection
  *
  * @return mixed|string
  */
 public function call($uri, $method, $parameters = [], $collection = true)
 {
     try {
         $origin_input = $this->request->input();
         $request = $this->request->create($uri, $method, $parameters);
         $this->request->replace($request->input());
         $dispatch = $this->router->dispatch($request);
         $this->request->replace($origin_input);
         return $this->getResponse($dispatch, $dispatch->getContent(), $collection);
     } catch (NotFoundHttpException $e) {
         throw new NotFoundHttpException('Request Not Found.');
     }
 }
开发者ID:killtw,项目名称:laravel-api,代码行数:21,代码来源:Api.php

示例2: saveFiles

 /**
  * File upload trait used in controllers to upload files
  */
 public function saveFiles(Request $request)
 {
     /**
      * Get Controller Name for uploade folder
      */
     $action = app('request')->route()->getAction();
     $controller = class_basename($action['controller']);
     $controller = explode('@', $controller);
     $folder_name = strtolower(str_replace('Controller', '/', $controller[0]));
     if (!file_exists(base_path('uploads/') . $folder_name)) {
         mkdir(base_path('uploads/') . $folder_name, 0777);
         mkdir(base_path('uploads/thumb/') . $folder_name, 0777);
     }
     foreach ($request->all() as $key => $value) {
         if ($request->hasFile($key)) {
             if ($request->has($key . '_w') && $request->has($key . '_h')) {
                 // Check file width
                 $filename = $folder_name . time() . '-' . $request->file($key)->getClientOriginalName();
                 $file = $request->file($key);
                 $image = Image::make($file);
                 Image::make($file)->resize(50, 50)->save(base_path('uploads/thumb') . '/' . $filename);
                 $width = $image->width();
                 $height = $image->height();
                 if ($width > $request->{$key . '_w'} && $height > $request->{$key . '_h'}) {
                     $image->resize($request->{$key . '_w'}, $request->{$key . '_h'});
                 } elseif ($width > $request->{$key . '_w'}) {
                     $image->resize($request->{$key . '_w'}, null, function ($constraint) {
                         $constraint->aspectRatio();
                     });
                 } elseif ($height > $request->{$key . '_w'}) {
                     $image->resize(null, $request->{$key . '_h'}, function ($constraint) {
                         $constraint->aspectRatio();
                     });
                 }
                 $image->save(base_path('uploads') . '/' . $filename);
                 $request->replace(array_merge($request->all(), [$key => $filename]));
                 $request->files->remove($key);
             } else {
                 $filename = $folder_name . time() . '-' . $request->file($key)->getClientOriginalName();
                 $request->file($key)->move(base_path('uploads'), $filename);
                 $request->replace(array_merge($request->all(), [$key => $filename]));
                 $request->files->remove($key);
             }
             // Check & Delete current file
             if ($request->has($key . '_c')) {
                 $this->deleteFiles($request->{$key . '_c'});
             }
         }
     }
 }
开发者ID:AmirHome,项目名称:AmirHome,代码行数:53,代码来源:FileUploadTrait.php

示例3: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $input = $request->all();
     array_set($input, 'match.id', $request->route('matchId'));
     $request->replace($input);
     return $next($request);
 }
开发者ID:bashmach,项目名称:ggf,代码行数:14,代码来源:BeforeMatchUpdateRequest.php

示例4: destroy

 /**
  * Unfallow a User
  *
  * @param $userIdToUnfallow
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy($userIdToUnfallow, Request $request)
 {
     $request->replace(array_add($request->all(), 'userId', Auth::id()));
     $this->dispatcher->dispatchFrom(UnfallowUser::class, $request);
     Flash::success('You have now unfallowed this user');
     return Redirect::back();
 }
开发者ID:sabahtalateh,项目名称:laracast,代码行数:14,代码来源:FallowersController.php

示例5: replaceRequestInput

 /**
  * Replace the request input with the previous request input.
  *
  * @return void
  */
 protected function replaceRequestInput()
 {
     array_pop($this->requestStack);
     $previous = end($this->requestStack);
     $this->router->setCurrentRequest($previous);
     $this->request->replace($previous->input());
 }
开发者ID:iwillhappy1314,项目名称:laravel-admin,代码行数:12,代码来源:Dispatcher.php

示例6: invoke

 /**
  * Call internal URI with parameters.
  *
  * @param  string $uri
  * @param  string $method
  * @param  array  $parameters
  * @return mixed
  */
 public function invoke($uri, $method, $parameters = array())
 {
     // Request URI.
     $uri = '/' . ltrim($uri, '/');
     // Parameters for GET, POST
     $parameters = $parameters ? current($parameters) : array();
     try {
         // store the original request data and route
         $originalInput = $this->request->input();
         $originalRoute = $this->router->getCurrentRoute();
         // create a new request to the API resource
         $request = $this->request->create($uri, strtoupper($method), $parameters);
         // replace the request input...
         $this->request->replace($request->input());
         $dispatch = $this->router->dispatch($request);
         if (method_exists($dispatch, 'getOriginalContent')) {
             $response = $dispatch->getOriginalContent();
         } else {
             $response = $dispatch->getContent();
         }
         // Decode json content.
         if ($dispatch->headers->get('content-type') == 'application/json') {
             if (function_exists('json_decode') and is_string($response)) {
                 $response = json_decode($response, true);
             }
         }
         // replace the request input and route back to the original state
         $this->request->replace($originalInput);
         $this->router->setCurrentRoute($originalRoute);
         return $response;
     } catch (NotFoundHttpException $e) {
     }
 }
开发者ID:ddedic,项目名称:nexsell,代码行数:41,代码来源:Api.php

示例7: it_sets_page_numbers_in_the_title

 /** @test */
 public function it_sets_page_numbers_in_the_title()
 {
     $request = new Request();
     $request->replace(['page' => '2']);
     $meta = new MetaDataService($request);
     $meta->setMeta('Bar');
     $this->assertEquals('Bar (Page 2) - Site Name', $meta->metaTitle());
 }
开发者ID:bhutanio,项目名称:laravel-utilities,代码行数:9,代码来源:MetaDataServiceTest.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle(Request $request, \Closure $next)
 {
     $input = $request->input(null, []);
     array_walk_recursive($input, function (&$val) {
         $val = trim($val);
     });
     $request->replace($input);
     return $next($request);
 }
开发者ID:LazyNewbie,项目名称:boilerplate,代码行数:16,代码来源:InputFilterMiddleware.php

示例9: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     if ('testing' === $this->app->environment() && $request->has('_token')) {
         $input = $request->all();
         $input['_token'] = $request->session()->token();
         // we need to update _token value to make sure we get the POST / PUT tests passed.
         Log::debug('Input token replaced (' . $input['_token'] . ').');
         $request->replace($input);
     }
     return $next($request);
 }
开发者ID:webenhanced,项目名称:firefly-iii,代码行数:19,代码来源:ReplaceTestVars.php

示例10: getOAuthToken

 /**
  * @param Request $request
  * @return \OAuth2\HttpFoundationBridge\Response
  */
 public function getOAuthToken(Request $request)
 {
     // adding the client secret into the request object
     $requestArray = $request->all();
     $requestArray['client_secret'] = env('APP_KEY');
     $request->replace($requestArray);
     $bridgedRequest = \OAuth2\HttpFoundationBridge\Request::createFromRequest($request->instance());
     $bridgedResponse = new \OAuth2\HttpFoundationBridge\Response();
     $bridgedResponse = \App::make('oauth2')->handleTokenRequest($bridgedRequest, $bridgedResponse);
     return $bridgedResponse;
 }
开发者ID:snehachavan21,项目名称:timesheet,代码行数:15,代码来源:OAuthController.php

示例11: saveFiles

 /**
  * File upload trait used in controllers to upload files
  */
 public function saveFiles(Request $request)
 {
     foreach ($request->all() as $key => $value) {
         if ($request->hasFile($key)) {
             $filename = time() . '-' . $request->file($key)->getClientOriginalName();
             $request->file($key)->move(public_path('uploads'), $filename);
             $request->replace(array_merge($request->all(), [$key => $filename]));
             $request->files->remove($key);
         }
     }
 }
开发者ID:premsingh4github,项目名称:laravel_quickadmin,代码行数:14,代码来源:FileUploadTrait.php

示例12: login

 protected function login(Request $request)
 {
     // we flash the request
     $request->flash();
     // we sanitize the entries
     $request->replace(InputSanitizer::sanitize($request->all()));
     // we set the remember to false if we do not find it
     $request->merge(['remember' => $request->get('remember', false)]);
     // we check the inputs validity
     $rules = ['email' => 'required|email', 'password' => 'required', 'remember' => 'required|boolean'];
     if (!Validation::check($request->all(), $rules)) {
         return redirect()->back();
     }
     // we try to authenticate the user
     try {
         if (!($user = Sentinel::authenticate($request->except('remember'), $request->get('remember')))) {
             Modal::alert([trans('auth.message.login.failure')], 'error');
             return redirect()->back();
         }
         // we notify the current user
         Modal::alert([trans('auth.message.login.success', ['name' => $user->first_name . " " . $user->last_name])], 'success');
         // redirect to the url stored in the session
         if ($url = session()->get('previous_url')) {
             session()->forget('previous_url');
             return redirect($url);
         } else {
             // or redirect to home
             return redirect(route('home'));
         }
     } catch (NotActivatedException $e) {
         // we log the error
         CustomLog::error($e);
         // we notify the current user
         Modal::alert([trans('auth.message.activation.failure'), trans('auth.message.activation.email.resend', ['email' => $request->get('email'), 'url' => route('account.activation_email', ['email' => $request->get('email')])])], 'error');
         return redirect()->back();
     } catch (ThrottlingException $e) {
         switch ($e->getType()) {
             case 'ip':
                 // we notify the current user
                 Modal::alert([trans('auth.message.throttle.ip', ['seconds' => $e->getDelay()])], 'error');
                 break;
             default:
                 // we notify the current user
                 Modal::alert([$e->getMessage()], 'error');
                 break;
         }
         return redirect()->back();
     } catch (Exception $e) {
         // we notify the current user
         \Modal::alert([trans('auth.message.login.error'), trans('global.message.global.failure.contact.support', ['email' => config('settings.support_email')])], 'error');
         return redirect()->back();
     }
 }
开发者ID:Okipa,项目名称:una.app,代码行数:53,代码来源:AuthController.php

示例13: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // if he has a get parameter d
     if ($request->has('d')) {
         $d = Demultiplexer::getByToken($request->input('d'));
         // if demultiplexer with this token exists it replace parameter d by all parameter for the request
         if ($d->params) {
             $request->replace(json_decode($d->params, true));
         }
     }
     return $next($request);
 }
开发者ID:frenchfrogs,项目名称:demultiplexer,代码行数:19,代码来源:DemultiplexerMiddleware.php

示例14: 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

示例15: postShortcut

 public function postShortcut(Request $request)
 {
     $request->replace($this->checkShortcut($request));
     if (Shortcuts::where('user_id', $request->input('user_id'))->where('name', $request->input('name'))->first()) {
         return json(error(2001));
     }
     if (Shortcuts::create($request->all())) {
         return json(['name' => $request->input('name')]);
     } else {
         return json(error(2000));
     }
 }
开发者ID:koyeo,项目名称:bichon,代码行数:12,代码来源:Config.php


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