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 $this->updates = [];
foreach (request('components.0.updates') as $key => $value) {
$this->updates[] = ['type' => 'syncInput', 'payload' => ['name' => $key]];
}
<?php $this->updates[] = ['type' => 'syncInput', 'payload' => ['name' => $key]];
}
foreach (request('components.0.calls') as $call) {
$this->updates[] = ['type' => 'callMethod', 'payload' => ['method' => $call['method']]];
}
}
<?php public function setOutputToFooHeader()
{
$this->output = request()->header('x-foo-header', '');
$this->altoutput = request()->header('x-bazz-header', '');
}
<?php public function setOutputToFooHeader()
{
$this->output = request()->header('x-foo-header', '');
$this->altoutput = request()->header('x-bazz-header', '');
}
public function render()
<?php public function initializeWithSearch()
{
$this->search = request()->query('search', $this->search);
}
}
<?php public function regenerateSession()
{
request()->session()->regenerate();
}
public function render()
<?php {
return function ($return) {
if ($return instanceof Responsable){
$return = $return->toResponse(request());
}
if ($this->valueIsntAFileResponse($return)) return;
<?php public function handle($filename)
{
abort_unless(request()->hasValidSignature(), 401);
return Utils::pretendPreviewResponseIsPreviewFile($filename);
}
<?php public function handle()
{
abort_unless(request()->hasValidSignature(), 401);
$disk = FileUploadConfiguration::disk();
<?php $disk = FileUploadConfiguration::disk();
$filePaths = $this->validateAndStore(request('files'), $disk);
return ['paths' => $filePaths];
}
<?php {
$route = request()->route();
if (! $route) return [];
<?php } catch (ModelNotFoundException $exception) {
if (method_exists($route,'getMissing') && $route->getMissing()) {
abort(
$route->getMissing()(request())
);
}
<?php {
Route::get('awesome-js/{framework}', ComponentWithModel::class)
->missing(function (Request $request) {
$this->assertEquals(request(), $request);
return redirect()->to('awesome-js/alpine');
});
<?php protected function resolvePage($alias, $default)
{
return request()->query($alias, $default);
}
protected function addUrlHook($pageName, $queryStringDetails)
<?php public function getFromUrlQueryString($name, $default = null)
{
if (! app('livewire')->isLivewireRequest()) {
$value = request()->query($this->urlName(), $default);