Redirect.php
TLDR
This file provides a facade class called Redirect
in the namespace Illuminate\Support\Facades
. This class serves as an interface to redirect HTTP requests in Laravel applications. It provides a set of static methods that can be used to redirect the user to specific routes or URLs.
Methods
back
This method redirects the user to the previous page. It accepts an optional status code, headers array, and fallback value parameters.
refresh
This method refreshes the current page. It accepts an optional status code and headers array parameters.
guest
This method redirects the user to a specific path as a guest. It accepts the path, an optional status code, headers array, and secure flag parameters.
intended
This method redirects the user to the intended URL, or a default URL if the intended URL is not available. It accepts an optional default URL, status code, headers array, and secure flag parameters.
to
This method redirects the user to a specific path. It accepts the path, an optional status code, headers array, and secure flag parameters.
away
This method redirects the user to a specific path as an external URL. It accepts the path, an optional status code, and headers array parameters.
secure
This method redirects the user to a specific path using HTTPS. It accepts the path, an optional status code, and headers array parameters.
route
This method redirects the user to a specific named route. It accepts the route name, parameters, an optional status code, and headers array parameters.
signedRoute
This method redirects the user to a specific signed named route. It accepts the route name, parameters, an optional expiration time, an optional status code, and headers array parameters.
temporarySignedRoute
This method redirects the user to a specific temporary signed named route. It accepts the route name, expiration time, parameters, an optional status code, and headers array parameters.
action
This method redirects the user to a specific action or controller method. It accepts the action or method name, parameters, an optional status code, and headers array parameters.
getUrlGenerator
This method returns the URL generator instance for the redirector.
setSession
This method sets the session instance for the redirector. It accepts an instance of the \Illuminate\Session\Store
class.
getIntendedUrl
This method retrieves the intended URL for the redirect. It returns a string or null value.
setIntendedUrl
This method sets the intended URL for the redirect. It accepts a string URL and returns the redirector instance.
macro
This method registers a new macro for the redirector. It accepts a macro name and an object or callable as the macro definition.
mixin
This method adds a mixin to the redirector. It accepts an object instance and an optional flag to replace existing mixins.
hasMacro
This method checks if a macro with a given name is registered. It accepts a macro name and returns a boolean value.
flushMacros
This method clears all registered macros for the redirector.
Classes
Redirect
This class extends the Facade
class and provides a set of static methods for redirecting HTTP requests in Laravel applications. It is a facade for the Redirector
class.
<?php
namespace Illuminate\Support\Facades;
/**
* @method static \Illuminate\Http\RedirectResponse back(int $status = 302, array $headers = [], mixed $fallback = false)
* @method static \Illuminate\Http\RedirectResponse refresh(int $status = 302, array $headers = [])
* @method static \Illuminate\Http\RedirectResponse guest(string $path, int $status = 302, array $headers = [], bool|null $secure = null)
* @method static \Illuminate\Http\RedirectResponse intended(mixed $default = '/', int $status = 302, array $headers = [], bool|null $secure = null)
* @method static \Illuminate\Http\RedirectResponse to(string $path, int $status = 302, array $headers = [], bool|null $secure = null)
* @method static \Illuminate\Http\RedirectResponse away(string $path, int $status = 302, array $headers = [])
* @method static \Illuminate\Http\RedirectResponse secure(string $path, int $status = 302, array $headers = [])
* @method static \Illuminate\Http\RedirectResponse route(string $route, mixed $parameters = [], int $status = 302, array $headers = [])
* @method static \Illuminate\Http\RedirectResponse signedRoute(string $route, mixed $parameters = [], \DateTimeInterface|\DateInterval|int|null $expiration = null, int $status = 302, array $headers = [])
* @method static \Illuminate\Http\RedirectResponse temporarySignedRoute(string $route, \DateTimeInterface|\DateInterval|int|null $expiration, mixed $parameters = [], int $status = 302, array $headers = [])
* @method static \Illuminate\Http\RedirectResponse action(string|array $action, mixed $parameters = [], int $status = 302, array $headers = [])
* @method static \Illuminate\Routing\UrlGenerator getUrlGenerator()
* @method static void setSession(\Illuminate\Session\Store $session)
* @method static string|null getIntendedUrl()
* @method static \Illuminate\Routing\Redirector setIntendedUrl(string $url)
* @method static void macro(string $name, object|callable $macro)
* @method static void mixin(object $mixin, bool $replace = true)
* @method static bool hasMacro(string $name)
* @method static void flushMacros()
*
* @see \Illuminate\Routing\Redirector
*/
class Redirect extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'redirect';
}
}