class Redirector (View source)

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected UrlGenerator $generator

The URL generator instance.

protected Store $session

The session store instance.

Methods

static void
macro(string $name, object|callable $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Checks if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

void
__construct(UrlGenerator $generator)

Create a new Redirector instance.

home(int $status = 302) deprecated

Create a new redirect response to the "home" route.

back(int $status = 302, array $headers = [], mixed $fallback = false)

Create a new redirect response to the previous location.

refresh(int $status = 302, array $headers = [])

Create a new redirect response to the current URI.

guest(string $path, int $status = 302, array $headers = [], bool|null $secure = null)

Create a new redirect response, while putting the current URL in the session.

intended(mixed $default = '/', int $status = 302, array $headers = [], bool|null $secure = null)

Create a new redirect response to the previously intended location.

to(string $path, int $status = 302, array $headers = [], bool|null $secure = null)

Create a new redirect response to the given path.

away(string $path, int $status = 302, array $headers = [])

Create a new redirect response to an external URL (no validation).

secure(string $path, int $status = 302, array $headers = [])

Create a new redirect response to the given HTTPS path.

route(string $route, mixed $parameters = [], int $status = 302, array $headers = [])

Create a new redirect response to a named route.

signedRoute(string $route, mixed $parameters = [], DateTimeInterface|DateInterval|int|null $expiration = null, int $status = 302, array $headers = [])

Create a new redirect response to a signed named route.

temporarySignedRoute(string $route, DateTimeInterface|DateInterval|int|null $expiration, mixed $parameters = [], int $status = 302, array $headers = [])

Create a new redirect response to a signed named route.

action(string|array $action, mixed $parameters = [], int $status = 302, array $headers = [])

Create a new redirect response to a controller action.

createRedirect(string $path, int $status, array $headers)

Create a new redirect response.

getUrlGenerator()

Get the URL generator instance.

void
setSession(Store $session)

Set the active session store.

string|null
getIntendedUrl()

Get the "intended" URL from the session.

$this
setIntendedUrl(string $url)

Set the "intended" URL in the session.

Details

static void macro(string $name, object|callable $macro)

Register a custom macro.

Parameters

string $name
object|callable $macro

Return Value

void

static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

static void flushMacros()

Flush the existing macros.

Return Value

void

static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

void __construct(UrlGenerator $generator)

Create a new Redirector instance.

Parameters

UrlGenerator $generator

Return Value

void

RedirectResponse home(int $status = 302) deprecated

deprecated Will be removed in a future Laravel version.

Create a new redirect response to the "home" route.

Parameters

int $status

Return Value

RedirectResponse

RedirectResponse back(int $status = 302, array $headers = [], mixed $fallback = false)

Create a new redirect response to the previous location.

Parameters

int $status
array $headers
mixed $fallback

Return Value

RedirectResponse

RedirectResponse refresh(int $status = 302, array $headers = [])

Create a new redirect response to the current URI.

Parameters

int $status
array $headers

Return Value

RedirectResponse

RedirectResponse guest(string $path, int $status = 302, array $headers = [], bool|null $secure = null)

Create a new redirect response, while putting the current URL in the session.

Parameters

string $path
int $status
array $headers
bool|null $secure

Return Value

RedirectResponse

RedirectResponse intended(mixed $default = '/', int $status = 302, array $headers = [], bool|null $secure = null)

Create a new redirect response to the previously intended location.

Parameters

mixed $default
int $status
array $headers
bool|null $secure

Return Value

RedirectResponse

RedirectResponse to(string $path, int $status = 302, array $headers = [], bool|null $secure = null)

Create a new redirect response to the given path.

Parameters

string $path
int $status
array $headers
bool|null $secure

Return Value

RedirectResponse

RedirectResponse away(string $path, int $status = 302, array $headers = [])

Create a new redirect response to an external URL (no validation).

Parameters

string $path
int $status
array $headers

Return Value

RedirectResponse

RedirectResponse secure(string $path, int $status = 302, array $headers = [])

Create a new redirect response to the given HTTPS path.

Parameters

string $path
int $status
array $headers

Return Value

RedirectResponse

RedirectResponse route(string $route, mixed $parameters = [], int $status = 302, array $headers = [])

Create a new redirect response to a named route.

Parameters

string $route
mixed $parameters
int $status
array $headers

Return Value

RedirectResponse

RedirectResponse signedRoute(string $route, mixed $parameters = [], DateTimeInterface|DateInterval|int|null $expiration = null, int $status = 302, array $headers = [])

Create a new redirect response to a signed named route.

Parameters

string $route
mixed $parameters
DateTimeInterface|DateInterval|int|null $expiration
int $status
array $headers

Return Value

RedirectResponse

RedirectResponse temporarySignedRoute(string $route, DateTimeInterface|DateInterval|int|null $expiration, mixed $parameters = [], int $status = 302, array $headers = [])

Create a new redirect response to a signed named route.

Parameters

string $route
DateTimeInterface|DateInterval|int|null $expiration
mixed $parameters
int $status
array $headers

Return Value

RedirectResponse

RedirectResponse action(string|array $action, mixed $parameters = [], int $status = 302, array $headers = [])

Create a new redirect response to a controller action.

Parameters

string|array $action
mixed $parameters
int $status
array $headers

Return Value

RedirectResponse

protected RedirectResponse createRedirect(string $path, int $status, array $headers)

Create a new redirect response.

Parameters

string $path
int $status
array $headers

Return Value

RedirectResponse

UrlGenerator getUrlGenerator()

Get the URL generator instance.

Return Value

UrlGenerator

void setSession(Store $session)

Set the active session store.

Parameters

Store $session

Return Value

void

string|null getIntendedUrl()

Get the "intended" URL from the session.

Return Value

string|null

$this setIntendedUrl(string $url)

Set the "intended" URL in the session.

Parameters

string $url

Return Value

$this