namespace Illuminate\Http;
use Closure;
use ArrayAccess;
use SplFileInfo;
use RuntimeException;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Support\Arrayable;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
// long namespace
class Request extends SymfonyRequest implements Arrayable, ArrayAccess
{// Request
use Macroable;// use trait
/**
* The decoded JSON content for the request.
*
* @var string
*/
protected $json;// The decoded JSON content for the request.
/**
* All of the converted files for the request.
*
* @var array
*/
protected $convertedFiles;//converted file
/**
* The user resolver callback.
*
* @var \Closure
*/
protected $userResolver;//The user resolver callback.
/**
* The route resolver callback.
*
* @var \Closure
*/
protected $routeResolver;// The route resolver callback.
/**
* Create a new Illuminate HTTP request from server variables.
*
* @return static
*/
public static function capture()
{
static::enableHttpMethodParameterOverride();// static::
return static::createFromBase(SymfonyRequest::createFromGlobals());
}// Create a new Illuminate HTTP request from server variables.
/**
* Return the Request instance.
*
* @return $this
*/
public function instance()
{
return $this;
}//Return the Request instance
/**
* Get the request method.
*
* @return string
*/
public function method()
{
return $this->getMethod();
}// get the request method.
/**
* Get the root URL for the application.
*
* @return string
*/
public function root()
{
return rtrim($this->getSchemeAndHttpHost().$this->getBaseUrl(), '/');
}// Get the root URL for the application.
/**
* Get the URL (no query string) for the request.
*
* @return string
*/
public function url()
{
return rtrim(preg_replace('/\?.*/', '', $this->getUri()), '/');
}// Get the URL (no query string) for the request.
/**
* Get the full URL for the request.
*
* @return string
*/
public function fullUrl()
{
$query = $this->getQueryString();// query ,get Query String
$question = $this->getBaseUrl().$this->getPathInfo() == '/' ? '/?' : '?';// question
return $query ? $this->url().$question.$query : $this->url();// query
}// Get the full URL for the request.
/**
* Get the current path info for the request.
*
* @return string
*/
public function path()
{
$pattern = trim($this->getPathInfo(), '/');
return $pattern == '' ? '/' : $pattern;
}//get Path
/**
* Get the current encoded path info for the request.
*
* @return string
*/
public function decodedPath()
{
return rawurldecode($this->path());
}//decode Path get the path
/**
* Get a segment from the URI (1 based index).
*
* @param int $index
* @param string|null $default
* @return string|null
*/
public function segment($index, $default = null)
{
return Arr::get($this->segments(), $index - 1, $default);
}//Get a segment from the URI (1 based index).
/**
* Get all of the segments for the request path.
*
* @return array
*/
public function segments()
{
$segments = explode('/', $this->path());
return array_values(array_filter($segments, function ($v) {
return $v != '';
}));// array_values.
}// Get all of the segments for the request path
/**
* Determine if the current request URI matches a pattern.
*
* @param mixed string
* @return bool
*/
public function is()
{
foreach (func_get_args() as $pattern) {
if (Str::is($pattern, urldecode($this->path()))) {
return true;
}
}
return false;
}// check current request.