[李景山php]每天laravel-20161019|RedirectResponse.php-2

来源:互联网 发布:莱斯特城奇迹 知乎 编辑:程序博客网 时间:2024/06/05 04:05
    /**     * 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}
0 0
原创粉丝点击