class Route (View source)

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
string $uri

The URI pattern the route responds to.

array $methods

The HTTP methods the route responds to.

array $action

The route action array.

bool $isFallback

Indicates whether the route is a fallback route.

mixed $controller

The controller instance.

array $defaults

The default values for the route.

array $wheres

The regular expression requirements.

array|null $parameters

The array of matched parameters.

array|null $parameterNames

The parameter names for the route.

protected array $originalParameters

The array of the matched parameters' original values.

protected bool $withTrashedBindings

Indicates "trashed" models can be retrieved when resolving implicit model bindings for this route.

protected int|null $lockSeconds

Indicates the maximum number of seconds the route should acquire a session lock for.

protected int|null $waitSeconds

Indicates the maximum number of seconds the route should wait while attempting to acquire a session lock.

array|null $computedMiddleware

The computed gathered middleware.

CompiledRoute $compiled

The compiled version of the route.

protected Router $router

The router instance used by the route.

protected Container $container

The container instance used by the route.

protected array $bindingFields

The fields that implicit binding should use for a given parameter.

static array $validators

The validators used by the routes.

Methods

$this
whereAlpha(array|string $parameters)

Specify that the given route parameters must be alphabetic.

$this
whereAlphaNumeric(array|string $parameters)

Specify that the given route parameters must be alphanumeric.

$this
whereNumber(array|string $parameters)

Specify that the given route parameters must be numeric.

$this
whereUlid(array|string $parameters)

Specify that the given route parameters must be ULIDs.

$this
whereUuid(array|string $parameters)

Specify that the given route parameters must be UUIDs.

$this
whereIn(array|string $parameters, array $values)

Specify that the given route parameters must be one of the given values.

$this
assignExpressionToParameters(array|string $parameters, string $expression)

Apply the given regular expression to the given parameters.

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.

array
resolveClassMethodDependencies(array $parameters, object $instance, string $method)

Resolve the object method's type-hinted dependencies.

array
resolveMethodDependencies(array $parameters, ReflectionFunctionAbstract $reflector)

Resolve the given method's type-hinted dependencies.

mixed
transformDependency(ReflectionParameter $parameter, array $parameters, object $skippableValue)

Attempt to transform the given parameter into a class instance.

bool
alreadyInParameters(string $class, array $parameters)

Determine if an object of the given class is in a list of parameters.

void
spliceIntoParameters(array $parameters, string $offset, mixed $value)

Splice the given value into the parameter list.

void
__construct(array|string $methods, string $uri, Closure|array $action)

Create a new Route instance.

array
parseAction(callable|array|null $action)

Parse the route action into a standard array.

mixed
run()

Run the route action and return the response.

bool
isControllerAction()

Checks whether the route's action is a controller.

mixed
runCallable()

Run the route action and return the response.

bool
isSerializedClosure()

Determine if the route action is a serialized Closure.

mixed
runController()

Run the route action and return the response.

mixed
getController()

Get the controller instance for the route.

string
getControllerClass()

Get the controller class used for the route.

string
getControllerMethod()

Get the controller method used for the route.

array
parseControllerCallback()

Parse the controller.

void
flushController()

Flush the cached container instance on the route.

bool
matches(Request $request, bool $includingMethod = true)

Determine if the route matches a given request.

CompiledRoute
compileRoute()

Compile the route into a Symfony CompiledRoute instance.

$this
bind(Request $request)

Bind the route to a given request for execution.

bool
hasParameters()

Determine if the route has parameters.

bool
hasParameter(string $name)

Determine a given parameter exists from the route.

string|object|null
parameter(string $name, string|object|null $default = null)

Get a given parameter from the route.

string|null
originalParameter(string $name, string|null $default = null)

Get original value of a given parameter from the route.

void
setParameter(string $name, string|object|null $value)

Set a parameter to the given value.

void
forgetParameter(string $name)

Unset a parameter on the route if it is set.

array
parameters()

Get the key / value list of parameters for the route.

array
originalParameters()

Get the key / value list of original parameters for the route.

array
parametersWithoutNulls()

Get the key / value list of parameters without null values.

array
parameterNames()

Get all of the parameter names for the route.

array
compileParameterNames()

Get the parameter names for the route.

array
signatureParameters(array $conditions = [])

Get the parameters that are listed in the route / controller signature.

string|null
bindingFieldFor(string|int $parameter)

Get the binding field for the given parameter.

array
bindingFields()

Get the binding fields for the route.

$this
setBindingFields(array $bindingFields)

Set the binding fields for the route.

string
parentOfParameter(string $parameter)

Get the parent parameter of the given parameter.

$this
withTrashed(bool $withTrashed = true)

Allow "trashed" models to be retrieved when resolving implicit model bindings for this route.

bool
allowsTrashedBindings()

Determines if the route allows "trashed" models to be retrieved when resolving implicit model bindings.

$this
defaults(string $key, mixed $value)

Set a default value for the route.

$this
setDefaults(array $defaults)

Set the default values for the route.

$this
where(array|string $name, string|null $expression = null)

Set a regular expression requirement on the route.

array
parseWhere(array|string $name, string $expression)

Parse arguments to the where method into an array.

$this
setWheres(array $wheres)

Set a list of regular expression requirements on the route.

$this
fallback()

Mark this route as a fallback route.

$this
setFallback(bool $isFallback)

Set the fallback value.

array
methods()

Get the HTTP verbs the route responds to.

bool
httpOnly()

Determine if the route only responds to HTTP requests.

bool
httpsOnly()

Determine if the route only responds to HTTPS requests.

bool
secure()

Determine if the route only responds to HTTPS requests.

$this|string|null
domain(string|null $domain = null)

Get or set the domain for the route.

string|null
getDomain()

Get the domain defined for the route.

string|null
getPrefix()

Get the prefix of the route instance.

$this
prefix(string $prefix)

Add a prefix to the route URI.

void
updatePrefixOnAction(string $prefix)

Update the "prefix" attribute on the action array.

string
uri()

Get the URI associated with the route.

$this
setUri(string $uri)

Set the URI that the route responds to.

string
parseUri(string $uri)

Parse the route URI and normalize / store any implicit binding fields.

string|null
getName()

Get the name of the route instance.

$this
name(string $name)

Add or change the route name.

bool
named(mixed ...$patterns)

Determine whether the route's name matches the given patterns.

$this
uses(Closure|array|string $action)

Set the handler for the route.

string
addGroupNamespaceToStringUses(string $action)

Parse a string based action for the "uses" fluent method.

string
getActionName()

Get the action name for the route.

string
getActionMethod()

Get the method name of the route action.

mixed
getAction(string|null $key = null)

Get the action array or one of its properties for the route.

$this
setAction(array $action)

Set the action array for the route.

Closure|null
getMissing()

Get the value of the action that should be taken on a missing model exception.

$this
missing(Closure $missing)

Define the callable that should be invoked on a missing model exception.

array
gatherMiddleware()

Get all middleware, including the ones from the controller.

$this|array
middleware(array|string|null $middleware = null)

Get or set the middlewares attached to the route.

$this
can(string $ability, array|string $models = [])

Specify that the "Authorize" / "can" middleware should be applied to the route with the given options.

array
controllerMiddleware()

Get the middleware for the route's controller.

array
staticallyProvidedControllerMiddleware(string $class, string $method)

Get the statically provided controller middleware for the given class and method.

$this
withoutMiddleware(array|string $middleware)

Specify middleware that should be removed from the given route.

array
excludedMiddleware()

Get the middleware should be removed from the route.

$this
scopeBindings()

Indicate that the route should enforce scoping of multiple implicit Eloquent bindings.

$this
withoutScopedBindings()

Indicate that the route should not enforce scoping of multiple implicit Eloquent bindings.

bool
enforcesScopedBindings()

Determine if the route should enforce scoping of multiple implicit Eloquent bindings.

bool
preventsScopedBindings()

Determine if the route should prevent scoping of multiple implicit Eloquent bindings.

$this
block(int|null $lockSeconds = 10, int|null $waitSeconds = 10)

Specify that the route should not allow concurrent requests from the same session.

$this
withoutBlocking()

Specify that the route should allow concurrent requests from the same session.

int|null
locksFor()

Get the maximum number of seconds the route's session lock should be held for.

int|null
waitsFor()

Get the maximum number of seconds to wait while attempting to acquire a session lock.

controllerDispatcher()

Get the dispatcher for the route's controller.

static array
getValidators()

Get the route validators for the instance.

Route
toSymfonyRoute()

Convert the route to a Symfony route.

array
getOptionalParameterNames()

Get the optional parameter names for the route.

CompiledRoute
getCompiled()

Get the compiled version of the route.

$this
setRouter(Router $router)

Set the router instance on the route.

$this
setContainer(Container $container)

Set the container instance on the route.

void
prepareForSerialization()

Prepare the route instance for serialization.

mixed
__get(string $key)

Dynamically access route parameters.

Details

$this whereAlpha(array|string $parameters)

Specify that the given route parameters must be alphabetic.

Parameters

array|string $parameters

Return Value

$this

$this whereAlphaNumeric(array|string $parameters)

Specify that the given route parameters must be alphanumeric.

Parameters

array|string $parameters

Return Value

$this

$this whereNumber(array|string $parameters)

Specify that the given route parameters must be numeric.

Parameters

array|string $parameters

Return Value

$this

$this whereUlid(array|string $parameters)

Specify that the given route parameters must be ULIDs.

Parameters

array|string $parameters

Return Value

$this

$this whereUuid(array|string $parameters)

Specify that the given route parameters must be UUIDs.

Parameters

array|string $parameters

Return Value

$this

$this whereIn(array|string $parameters, array $values)

Specify that the given route parameters must be one of the given values.

Parameters

array|string $parameters
array $values

Return Value

$this

protected $this assignExpressionToParameters(array|string $parameters, string $expression)

Apply the given regular expression to the given parameters.

Parameters

array|string $parameters
string $expression

Return Value

$this

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

protected array resolveClassMethodDependencies(array $parameters, object $instance, string $method)

Resolve the object method's type-hinted dependencies.

Parameters

array $parameters
object $instance
string $method

Return Value

array

array resolveMethodDependencies(array $parameters, ReflectionFunctionAbstract $reflector)

Resolve the given method's type-hinted dependencies.

Parameters

array $parameters
ReflectionFunctionAbstract $reflector

Return Value

array

protected mixed transformDependency(ReflectionParameter $parameter, array $parameters, object $skippableValue)

Attempt to transform the given parameter into a class instance.

Parameters

ReflectionParameter $parameter
array $parameters
object $skippableValue

Return Value

mixed

protected bool alreadyInParameters(string $class, array $parameters)

Determine if an object of the given class is in a list of parameters.

Parameters

string $class
array $parameters

Return Value

bool

protected void spliceIntoParameters(array $parameters, string $offset, mixed $value)

Splice the given value into the parameter list.

Parameters

array $parameters
string $offset
mixed $value

Return Value

void

void __construct(array|string $methods, string $uri, Closure|array $action)

Create a new Route instance.

Parameters

array|string $methods
string $uri
Closure|array $action

Return Value

void

protected array parseAction(callable|array|null $action)

Parse the route action into a standard array.

Parameters

callable|array|null $action

Return Value

array

Exceptions

UnexpectedValueException

mixed run()

Run the route action and return the response.

Return Value

mixed

protected bool isControllerAction()

Checks whether the route's action is a controller.

Return Value

bool

protected mixed runCallable()

Run the route action and return the response.

Return Value

mixed

protected bool isSerializedClosure()

Determine if the route action is a serialized Closure.

Return Value

bool

protected mixed runController()

Run the route action and return the response.

Return Value

mixed

Exceptions

NotFoundHttpException

mixed getController()

Get the controller instance for the route.

Return Value

mixed

string getControllerClass()

Get the controller class used for the route.

Return Value

string

protected string getControllerMethod()

Get the controller method used for the route.

Return Value

string

protected array parseControllerCallback()

Parse the controller.

Return Value

array

void flushController()

Flush the cached container instance on the route.

Return Value

void

bool matches(Request $request, bool $includingMethod = true)

Determine if the route matches a given request.

Parameters

Request $request
bool $includingMethod

Return Value

bool

protected CompiledRoute compileRoute()

Compile the route into a Symfony CompiledRoute instance.

Return Value

CompiledRoute

$this bind(Request $request)

Bind the route to a given request for execution.

Parameters

Request $request

Return Value

$this

bool hasParameters()

Determine if the route has parameters.

Return Value

bool

bool hasParameter(string $name)

Determine a given parameter exists from the route.

Parameters

string $name

Return Value

bool

string|object|null parameter(string $name, string|object|null $default = null)

Get a given parameter from the route.

Parameters

string $name
string|object|null $default

Return Value

string|object|null

string|null originalParameter(string $name, string|null $default = null)

Get original value of a given parameter from the route.

Parameters

string $name
string|null $default

Return Value

string|null

void setParameter(string $name, string|object|null $value)

Set a parameter to the given value.

Parameters

string $name
string|object|null $value

Return Value

void

void forgetParameter(string $name)

Unset a parameter on the route if it is set.

Parameters

string $name

Return Value

void

array parameters()

Get the key / value list of parameters for the route.

Return Value

array

Exceptions

LogicException

array originalParameters()

Get the key / value list of original parameters for the route.

Return Value

array

Exceptions

LogicException

array parametersWithoutNulls()

Get the key / value list of parameters without null values.

Return Value

array

array parameterNames()

Get all of the parameter names for the route.

Return Value

array

protected array compileParameterNames()

Get the parameter names for the route.

Return Value

array

array signatureParameters(array $conditions = [])

Get the parameters that are listed in the route / controller signature.

Parameters

array $conditions

Return Value

array

string|null bindingFieldFor(string|int $parameter)

Get the binding field for the given parameter.

Parameters

string|int $parameter

Return Value

string|null

array bindingFields()

Get the binding fields for the route.

Return Value

array

$this setBindingFields(array $bindingFields)

Set the binding fields for the route.

Parameters

array $bindingFields

Return Value

$this

string parentOfParameter(string $parameter)

Get the parent parameter of the given parameter.

Parameters

string $parameter

Return Value

string

$this withTrashed(bool $withTrashed = true)

Allow "trashed" models to be retrieved when resolving implicit model bindings for this route.

Parameters

bool $withTrashed

Return Value

$this

bool allowsTrashedBindings()

Determines if the route allows "trashed" models to be retrieved when resolving implicit model bindings.

Return Value

bool

$this defaults(string $key, mixed $value)

Set a default value for the route.

Parameters

string $key
mixed $value

Return Value

$this

$this setDefaults(array $defaults)

Set the default values for the route.

Parameters

array $defaults

Return Value

$this

$this where(array|string $name, string|null $expression = null)

Set a regular expression requirement on the route.

Parameters

array|string $name
string|null $expression

Return Value

$this

protected array parseWhere(array|string $name, string $expression)

Parse arguments to the where method into an array.

Parameters

array|string $name
string $expression

Return Value

array

$this setWheres(array $wheres)

Set a list of regular expression requirements on the route.

Parameters

array $wheres

Return Value

$this

$this fallback()

Mark this route as a fallback route.

Return Value

$this

$this setFallback(bool $isFallback)

Set the fallback value.

Parameters

bool $isFallback

Return Value

$this

array methods()

Get the HTTP verbs the route responds to.

Return Value

array

bool httpOnly()

Determine if the route only responds to HTTP requests.

Return Value

bool

bool httpsOnly()

Determine if the route only responds to HTTPS requests.

Return Value

bool

bool secure()

Determine if the route only responds to HTTPS requests.

Return Value

bool

$this|string|null domain(string|null $domain = null)

Get or set the domain for the route.

Parameters

string|null $domain

Return Value

$this|string|null

string|null getDomain()

Get the domain defined for the route.

Return Value

string|null

string|null getPrefix()

Get the prefix of the route instance.

Return Value

string|null

$this prefix(string $prefix)

Add a prefix to the route URI.

Parameters

string $prefix

Return Value

$this

protected void updatePrefixOnAction(string $prefix)

Update the "prefix" attribute on the action array.

Parameters

string $prefix

Return Value

void

string uri()

Get the URI associated with the route.

Return Value

string

$this setUri(string $uri)

Set the URI that the route responds to.

Parameters

string $uri

Return Value

$this

protected string parseUri(string $uri)

Parse the route URI and normalize / store any implicit binding fields.

Parameters

string $uri

Return Value

string

string|null getName()

Get the name of the route instance.

Return Value

string|null

$this name(string $name)

Add or change the route name.

Parameters

string $name

Return Value

$this

bool named(mixed ...$patterns)

Determine whether the route's name matches the given patterns.

Parameters

mixed ...$patterns

Return Value

bool

$this uses(Closure|array|string $action)

Set the handler for the route.

Parameters

Closure|array|string $action

Return Value

$this

protected string addGroupNamespaceToStringUses(string $action)

Parse a string based action for the "uses" fluent method.

Parameters

string $action

Return Value

string

string getActionName()

Get the action name for the route.

Return Value

string

string getActionMethod()

Get the method name of the route action.

Return Value

string

mixed getAction(string|null $key = null)

Get the action array or one of its properties for the route.

Parameters

string|null $key

Return Value

mixed

$this setAction(array $action)

Set the action array for the route.

Parameters

array $action

Return Value

$this

Closure|null getMissing()

Get the value of the action that should be taken on a missing model exception.

Return Value

Closure|null

$this missing(Closure $missing)

Define the callable that should be invoked on a missing model exception.

Parameters

Closure $missing

Return Value

$this

array gatherMiddleware()

Get all middleware, including the ones from the controller.

Return Value

array

$this|array middleware(array|string|null $middleware = null)

Get or set the middlewares attached to the route.

Parameters

array|string|null $middleware

Return Value

$this|array

$this can(string $ability, array|string $models = [])

Specify that the "Authorize" / "can" middleware should be applied to the route with the given options.

Parameters

string $ability
array|string $models

Return Value

$this

array controllerMiddleware()

Get the middleware for the route's controller.

Return Value

array

protected array staticallyProvidedControllerMiddleware(string $class, string $method)

Get the statically provided controller middleware for the given class and method.

Parameters

string $class
string $method

Return Value

array

$this withoutMiddleware(array|string $middleware)

Specify middleware that should be removed from the given route.

Parameters

array|string $middleware

Return Value

$this

array excludedMiddleware()

Get the middleware should be removed from the route.

Return Value

array

$this scopeBindings()

Indicate that the route should enforce scoping of multiple implicit Eloquent bindings.

Return Value

$this

$this withoutScopedBindings()

Indicate that the route should not enforce scoping of multiple implicit Eloquent bindings.

Return Value

$this

bool enforcesScopedBindings()

Determine if the route should enforce scoping of multiple implicit Eloquent bindings.

Return Value

bool

bool preventsScopedBindings()

Determine if the route should prevent scoping of multiple implicit Eloquent bindings.

Return Value

bool

$this block(int|null $lockSeconds = 10, int|null $waitSeconds = 10)

Specify that the route should not allow concurrent requests from the same session.

Parameters

int|null $lockSeconds
int|null $waitSeconds

Return Value

$this

$this withoutBlocking()

Specify that the route should allow concurrent requests from the same session.

Return Value

$this

int|null locksFor()

Get the maximum number of seconds the route's session lock should be held for.

Return Value

int|null

int|null waitsFor()

Get the maximum number of seconds to wait while attempting to acquire a session lock.

Return Value

int|null

ControllerDispatcher controllerDispatcher()

Get the dispatcher for the route's controller.

Return Value

ControllerDispatcher

static array getValidators()

Get the route validators for the instance.

Return Value

array

Route toSymfonyRoute()

Convert the route to a Symfony route.

Return Value

Route

protected array getOptionalParameterNames()

Get the optional parameter names for the route.

Return Value

array

CompiledRoute getCompiled()

Get the compiled version of the route.

Return Value

CompiledRoute

$this setRouter(Router $router)

Set the router instance on the route.

Parameters

Router $router

Return Value

$this

$this setContainer(Container $container)

Set the container instance on the route.

Parameters

Container $container

Return Value

$this

void prepareForSerialization()

Prepare the route instance for serialization.

Return Value

void

Exceptions

LogicException

mixed __get(string $key)

Dynamically access route parameters.

Parameters

string $key

Return Value

mixed