The
request
function returns the current request instance or obtains an input field's value from the current request:<?php $request = request();
$value = request('key', $default);
<?php protected function url()
{
return URL::tidy(request()->url());
}
protected function log($message)
<?php {
$ips = array_get($this->config, 'allowed', []);
if (! in_array(request()->ip(), $ips)) {
abort(403);
}
}
<?php public function store()
{
$this->password = request('password');
$this->tokenData = session('statamic:protect:password.tokens.'.request('token'));
if (! $this->tokenData) {
<?php public function store()
{
$this->password = request('password');
$this->tokenData = session('statamic:protect:password.tokens.'.request('token'));
if (! $this->tokenData) {
return back()->withErrors(['token' => 'Invalid or expired token.'], 'passwordProtect');
<?php protected function expireToken()
{
$token = request('token');
session()->forget("statamic:protect:password.tokens.$token");
<?php public function passwordForm()
{
if (! $token = request('token')) {
return $this->parse([
'errors' => [],
'no_token' => true,
<?php $html = $this->formOpen(route('statamic.password.reset.action'), 'POST', $knownParams);
$html .= '<input type="hidden" name="token" value="'.request('token').'" />';
if ($redirect = $this->params->get('redirect')) {
$html .= '<input type="hidden" name="redirect" value="'.$redirect.'" />';
<?php $return = $this->params->get('redirect');
if ($this->params->bool('allow_request_redirect', false)) {
$return = request()->input('redirect', $return);
}
return $return;
<?php {
$pattern = preg_quote(config('statamic.cp.route'), '#').'/'.$this->active;
return preg_match('#'.$pattern.'#', request()->decodedPath()) === 1;
}
<?php private function isOnAllowedRoute()
{
if (! $route = optional(request()->route())->getName()) {
return false;
}
<?php protected function getAuthExceptionRedirectUrl()
{
$referrer = request()->header('referer');
<?php if (request()->getUri() === $target) {
return cp_route('unauthorized');
}
<?php public function withQueryString()
{
$this->appends(request()->query());
return $this;
}
<?php if (! $controller) {
$file = pathinfo(request()->getScriptName())['basename'];
$prepend = Str::removeRight($prepend, $file);
}
<?php {
collect($this->fields())
->filter(function ($config, $handle) {
return Arr::get($config, 'type') === 'assets' && request()->hasFile($handle);
})
->each(function ($config, $handle) {
Arr::set($this->data, $handle, AssetsUploader::field($config)->upload(request()->file($handle)));