[李景山php]每天laravel-20161019|RedirectResponse.php-2
2016-08-24 09:10
766 查看
/** * Add multiple cookies to the response. * * @param array $cookies * @return $this */ public function withCookies(array $cookies) { foreach ($cookies as $cookie) { $this->headers->setCookie($cookie); }// loop cookie array, return $this; }// Add multiple cookies /** * Flash an array of input to the session. * * @param array $input * @return $this */ public function withInput(array $input = null) { $input = $input ?: $this->request->input();//$input and the request input $this->session->flashInput($data = array_filter($input, $callback = function (&$value) use (&$callback) { if (is_array($value)) { $value = array_filter($value, $callback); }// use this recursion function return ! $value instanceof SymfonyUploadedFile; }));// loop this input, and been filter by callback default function is a return $this;// return this instance }//flash an array of input to the session /** * Flash an array of input to the session. * * @param mixed string * @return $this */ public function onlyInput() { return $this->withInput($this->request->only(func_get_args())); }// first get the parameters about all insert // and then get the only,and then get the input /** * Flash an array of input to the session. * * @param mixed string * @return \Illuminate\Http\RedirectResponse */ public function exceptInput() { return $this->withInput($this->request->except(func_get_args())); }// flash an except array of input to the session /** * Flash a container of errors to the session. * * @param \Illuminate\Contracts\Support\MessageProvider|array|string $provider * @param string $key * @return $this */ public function withErrors($provider, $key = 'default') { $value = $this->parseErrors($provider);// value like parse Errors $this->session->flash( 'errors', $this->session->get('errors', new ViewErrorBag)->put($key, $value) );//a wrap function return $this; }//flash a error and errors, /** * Parse the given errors into an appropriate value. * * @param \Illuminate\Contracts\Support\MessageProvider|array|string $provider * @return \Illuminate\Support\MessageBag */ protected function parseErrors($provider) { if ($provider instanceof MessageProvider) { return $provider->getMessageBag(); }// type 1 //type 2 return new MessageBag((array) $provider); }// parse the given errors into an appropriate value /** * Get the request instance. * * @return \Illuminate\Http\Request|null */ public function getRequest() { return $this->request; }// big get /** * Set the request instance. * * @param \Illuminate\Http\Request $request * @return void */ public function setRequest(Request $request) { $this->request = $request; }// big set /** * Get the session store implementation. * * @return \Illuminate\Session\Store|null */ public function getSession() { return $this->session; }// get session /** * Set the session store implementation. * * @param \Illuminate\Session\Store $session * @return void */ public function setSession(SessionStore $session) { $this->session = $session; }// set session /** * Dynamically bind flash data in the session. * * @param string $method * @param array $parameters * @return $this * * @throws \BadMethodCallException */ public function __call($method, $parameters) { if (Str::startsWith($method, 'with')) { return $this->with(Str::snake(substr($method, 4)), $parameters[0]); }// a magic function throw new BadMethodCallException("Method [$method] does not exist on Redirect."); }// Dynamically bind flash data in the session }
相关文章推荐
- [李景山php]每天laravel-20161018|RedirectResponse.php-1
- [李景山php]每天laravel-20161018|RedirectResponse.php-1
- [李景山php]每天laravel-20161017|ResponseTrait.php
- [李景山php]每天laravel-20161017|ResponseTrait.php
- [李景山php]每天laravel-20161016|JsonResponse.php
- [李景山php]每天laravel-20161015|HttpResponseWxception.php-15
- [李景山php]每天laravel-20161016|JsonResponse.php
- [李景山php]每天laravel-20160907|Dispatcher-7
- [李景山php]每天laravel-20160828|McryptEncrypter-2
- [李景山php]每天laravel-20160828|McryptEncrypter-2
- [李景山php]每天laravel-20160906|Dispatcher-6
- [李景山php]每天laravel-20160901|Dispatcher-1
- [李景山php]每天laravel-20160901|Dispatcher-1
- [李景山php]每天laravel-20160825|Encrypter
- [李景山php]每天laravel-20160904|Dispatcher-4
- [李景山php]每天laravel-20160905|Dispatcher-5
- [李景山php]每天laravel-20160902|Dispatcher-2
- [李景山php]每天laravel-20160827|McryptEncrypter-1
- [李景山php]每天laravel-20160902|Dispatcher-2
- [李景山php]每天laravel-20160829|McryptEncrypter-3