/** * determine if the current request url and query string matches a pattern. * * @param mixed string * @ Return bool */public function fullurlis () {// check string like url $url = $this->fullurl (); foreach (func_get_ Args () as $pattern) { if (Str::is ($pattern, $url)) { return true; } }// foreach like loop it return false;} Determine if the current request url and query string matches a pattern./** * Determine if the request is the result of an ajax call. * * @return bool */ Public function ajax () { return $this->isxmlhttprequest ();} determine if the request is the result of an ajax call./** * determine if the request is the result of an pjax call. * * @return bool */public function pjax () { return $this->headers->get (' X-pjax ') == true;} determine if the request is the result of an pjax call./** * Determine if the request is over HTTPS. * * @return bool */public function secure () { return $this->issecure ();} Determine if the request is over https./** * returns the client ip address. * * @return string */public function ip () { return $this->getclientip ();} returns the client ip address./** * returns the client ip addresses. * * @return array */public function ips () { return $this->getclientips ();} Returns the client ip address./** * determine if the request contains a given input item key. * * @param string| array $key * @return bool */public function exists ($key) {//determine if the request contains a given input item key. $keys = is_array ($key) ? $key : func_get_args ();// $key get the key $input = $this->all ()// get all input request foreach ($keys as $value) { if (! array_key_exists ($value, $input)) { return false; } } return true;} /** * determine if the request contains a non-empty value for an input item. * * @param string|array $key * @return bool */public function has ($key) {// determine if the request contains a non-empty value for an input item. $keys = is_array ($key)  ?  $key : func_get_args (); foreach ($keys as $value) { if ($this->isemptystring ($value)) { return false; } } return true;} /** * determine if the given input key is an empty string for "has" . * * @param string $key * @return bool */protected function isemptystring ($key) { $value = $this->input ($key); $boolOrArray = is_bool ($value) | | is_array ($value); return ! $boolOrArray && trim (( String) $value) === ';} determine if the given input key is an empty string for "has"/** * Get all of the input and files for the request. * * @ Return array */public function all () { return array_replace_ Recursive ($this->input (), $this->allfiles ());} get all of the input and files for the request./** * Retrieve an input item from the request. * * @param string $key * @param string|array|null $default * @ Return string|array */public function input ($key = null, $default = null) { $input = $this->getinputsource ()->all () + $this- >query->all (); return data_get ($input,  , $key, $default);} Retrieve an input item from the request./** * get a subset of the items from the input data. * * @param array|mixed $keys * @return array */public function only ($keys) {//get a subset of the items from the input data. $keys = is_array ($keys) ? $keys : func_get_args ();// keys $results = [];// get result $input = $this- >all ();// get the input foreach ($keys as $key) { loop keys arr::set ($results, $key, data_ Get ($input, $key)); } return $results;} /** * get all of the input except for a specified array of items. * * @param array|mixed $keys * @return Array */public function except ($keys) { $keys = is_array ($keys) ? $keys : func_get_args (); $results = $this->all (); arr::forget ($results, $keys); return $results;} get all of the input except for a specified array of items./** * retrieve a query string item from the request. * * @param string $key * @param string|array|null $default * @return string|array */public function query ($key = null, $default =&Nbsp;null) { return $this->retrieveitem (' query ', $key, $default);} Retrieve a query string item from the request./** * determine if a cookie is set on the request. * * @param string $key * @return bool */public function hascookie ($ Key) { return ! is_null ($this->cookie ($key));// is_null}//determine if a cookie is set on the request./** * retrieve a cookie from the request. * * @param string $key * @param string|array|null $default * @return string|array */public function cookie ($key = null, $default = null) { return $this->retrIeveitem (' Cookies ', $key, $default);} Retrieve a cookie from the request./** * get an array of all of the files on the request. * * @return array */public function allfiles () { $files = $this->files-> All (); return $this->convertedfiles ? $this->convertedfiles : $this->convertedfiles = $this->convertuploadedfiles ($files);} get allfiles/** * convert the given array of symfony uploadedfiles to custom laravel uploadedfiles. * * @param array $files * @return array */protected function convertuploadedfiles (array $files) {//convert the given array of Smfony UploadedFiles to custom laravel UploadedFiles. return array_map (function ($file) { if (Is_null ($file) | | (Is_array ($file) && empty (Array_filter ($file))) { return $file; } return is_array ($file) ? $this Convertuploadedfiles ($file) : uploadedfile::createfrombase ($file); }, $files);//return array_map}/** * retrieve a file from the request. * * @param string $key * @param mixed $default * @return \symfony\component\httpfoundation\file\uploadedfile|array|null */public function file ($key = null, $default = null) { return data_get ($this->allfiles (), $key, $default);} retrieve a file from the request./** * determine if the uploaded data contains a file. * * @param string $key * @return bool */public function hasfile ($key) {//determine if the uploaded data contains a file. if (! is_array ($ files = $this->file ($key))) { $files = [$files]; } foreach ($files as $file) { if ( $this->isvalidfile ($file)) { return true; } } return false;}
This article is from the "Focus on PHP" blog, please be sure to keep this source http://jingshanls.blog.51cto.com/3357095/1842714
[Li Jingshan php] every day laravel-20161021| Request.php-2