class RouteRegistrar

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected Router $router

The router instance.

protected array $attributes

The attributes to pass on to the router.

protected string[] $passthru

The methods to dynamically pass through to the router.

protected string[] $allowedAttributes

The attributes that can be set through this class.

protected array $aliases

The attributes that are aliased.

Methods

whereAlpha(array|string $parameters)

Specify that the given route parameters must be alphabetic.

whereAlphaNumeric(array|string $parameters)

Specify that the given route parameters must be alphanumeric.

whereNumber(array|string $parameters)

Specify that the given route parameters must be numeric.

whereUlid(array|string $parameters)

Specify that the given route parameters must be ULIDs.

whereUuid(array|string $parameters)

Specify that the given route parameters must be UUIDs.

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

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

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

Apply the given regular expression to the given parameters.

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

Register a custom macro.

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

Mix another object into the class.

static bool
hasMacro(string $name)

Check 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 into the route registrar.

__construct(Router $router)

Create a new route registrar instance.

attribute(string $key, mixed $value)

Set the value for a given attribute.

resource(string $name, string $controller, array $options = [])

Route a resource to a controller.

apiResource(string $name, string $controller, array $options = [])

Route an API resource to a controller.

singleton(string $name, string $controller, array $options = [])

Route a singleton resource to a controller.

apiSingleton(string $name, string $controller, array $options = [])

Route an API singleton resource to a controller.

group(Closure|array|string $callback)

Create a route group with shared attributes.

match(array|string $methods, string $uri, Closure|array|string|null $action = null)

Register a new route with the given verbs.

registerRoute(string $method, string $uri, Closure|array|string|null $action = null)

Register a new route with the router.

array
compileAction(Closure|array|string|null $action)

Compile the action into an array including the attributes.

static void
flushState()

Flush all static state.

any(string $uri, Closure|array|string|null $action = 'null')

No description

delete(string $uri, Closure|array|string|null $action = 'null')

No description

get(string $uri, Closure|array|string|null $action = 'null')

No description

options(string $uri, Closure|array|string|null $action = 'null')

No description

patch(string $uri, Closure|array|string|null $action = 'null')

No description

post(string $uri, Closure|array|string|null $action = 'null')

No description

put(string $uri, Closure|array|string|null $action = 'null')

No description

as(string $value)

No description

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

No description

controller(string $controller)

No description

domain(BackedEnum|string $value)

No description

middleware(null|array|string $middleware)

No description

missing(Closure $missing)

No description

name(BackedEnum|string $value)

No description

namespace(null|string $value)

No description

prefix(string $prefix)

No description

scopeBindings()

No description

static void
where(array $where)

No description

withoutMiddleware(array|string $middleware)

No description

Details

CreatesRegularExpressionRouteConstraints whereAlpha(array|string $parameters)

Specify that the given route parameters must be alphabetic.

Parameters

array|string $parameters

Return Value

CreatesRegularExpressionRouteConstraints

CreatesRegularExpressionRouteConstraints whereAlphaNumeric(array|string $parameters)

Specify that the given route parameters must be alphanumeric.

Parameters

array|string $parameters

Return Value

CreatesRegularExpressionRouteConstraints

CreatesRegularExpressionRouteConstraints whereNumber(array|string $parameters)

Specify that the given route parameters must be numeric.

Parameters

array|string $parameters

Return Value

CreatesRegularExpressionRouteConstraints

CreatesRegularExpressionRouteConstraints whereUlid(array|string $parameters)

Specify that the given route parameters must be ULIDs.

Parameters

array|string $parameters

Return Value

CreatesRegularExpressionRouteConstraints

CreatesRegularExpressionRouteConstraints whereUuid(array|string $parameters)

Specify that the given route parameters must be UUIDs.

Parameters

array|string $parameters

Return Value

CreatesRegularExpressionRouteConstraints

CreatesRegularExpressionRouteConstraints 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

CreatesRegularExpressionRouteConstraints

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

Apply the given regular expression to the given parameters.

Parameters

array|string $parameters
string $expression

Return Value

CreatesRegularExpressionRouteConstraints

in Macroable at line 28
static void macro(string $name, callable|object $macro)

Register a custom macro.

Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.

Parameters

string $name
callable|object $macro

Return Value

void

in Macroable at line 41
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 57
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 68
static void flushMacros()

Flush the existing macros.

Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.

Return Value

void

in Macroable at line 78
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 248
mixed __call(string $method, array $parameters)

Dynamically handle calls into the route registrar.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 98
__construct(Router $router)

Create a new route registrar instance.

Parameters

Router $router

at line 108
RouteRegistrar attribute(string $key, mixed $value)

Set the value for a given attribute.

Parameters

string $key
mixed $value

Return Value

RouteRegistrar

Exceptions

InvalidArgumentException

at line 147
PendingResourceRegistration resource(string $name, string $controller, array $options = [])

Route a resource to a controller.

Parameters

string $name
string $controller
array $options

Return Value

PendingResourceRegistration

at line 155
PendingResourceRegistration apiResource(string $name, string $controller, array $options = [])

Route an API resource to a controller.

Parameters

string $name
string $controller
array $options

Return Value

PendingResourceRegistration

at line 163
PendingSingletonResourceRegistration singleton(string $name, string $controller, array $options = [])

Route a singleton resource to a controller.

Parameters

string $name
string $controller
array $options

Return Value

PendingSingletonResourceRegistration

at line 171
PendingSingletonResourceRegistration apiSingleton(string $name, string $controller, array $options = [])

Route an API singleton resource to a controller.

Parameters

string $name
string $controller
array $options

Return Value

PendingSingletonResourceRegistration

at line 179
RouteRegistrar group(Closure|array|string $callback)

Create a route group with shared attributes.

Parameters

Closure|array|string $callback

Return Value

RouteRegistrar

at line 189
Route match(array|string $methods, string $uri, Closure|array|string|null $action = null)

Register a new route with the given verbs.

Parameters

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

Return Value

Route

at line 197
protected Route registerRoute(string $method, string $uri, Closure|array|string|null $action = null)

Register a new route with the router.

Parameters

string $method
string $uri
Closure|array|string|null $action

Return Value

Route

at line 209
protected array compileAction(Closure|array|string|null $action)

Compile the action into an array including the attributes.

Parameters

Closure|array|string|null $action

Return Value

array

at line 236
static void flushState()

Flush all static state.

Return Value

void

at line 37
Route any(string $uri, Closure|array|string|null $action = 'null')

No description

Parameters

string $uri
Closure|array|string|null $action

Return Value

Route

at line 37
Route delete(string $uri, Closure|array|string|null $action = 'null')

No description

Parameters

string $uri
Closure|array|string|null $action

Return Value

Route

at line 37
Route get(string $uri, Closure|array|string|null $action = 'null')

No description

Parameters

string $uri
Closure|array|string|null $action

Return Value

Route

at line 37
Route options(string $uri, Closure|array|string|null $action = 'null')

No description

Parameters

string $uri
Closure|array|string|null $action

Return Value

Route

at line 37
Route patch(string $uri, Closure|array|string|null $action = 'null')

No description

Parameters

string $uri
Closure|array|string|null $action

Return Value

Route

at line 37
Route post(string $uri, Closure|array|string|null $action = 'null')

No description

Parameters

string $uri
Closure|array|string|null $action

Return Value

Route

at line 37
Route put(string $uri, Closure|array|string|null $action = 'null')

No description

Parameters

string $uri
Closure|array|string|null $action

Return Value

Route

at line 37
RouteRegistrar as(string $value)

No description

Parameters

string $value

Return Value

RouteRegistrar

at line 37
RouteRegistrar can(UnitEnum|string $ability, array|string $models = '[]')

No description

Parameters

UnitEnum|string $ability
array|string $models

Return Value

RouteRegistrar

at line 37
RouteRegistrar controller(string $controller)

No description

Parameters

string $controller

Return Value

RouteRegistrar

at line 37
RouteRegistrar domain(BackedEnum|string $value)

No description

Parameters

BackedEnum|string $value

Return Value

RouteRegistrar

at line 37
RouteRegistrar middleware(null|array|string $middleware)

No description

Parameters

null|array|string $middleware

Return Value

RouteRegistrar

at line 37
RouteRegistrar missing(Closure $missing)

No description

Parameters

Closure $missing

Return Value

RouteRegistrar

at line 37
RouteRegistrar name(BackedEnum|string $value)

No description

Parameters

BackedEnum|string $value

Return Value

RouteRegistrar

at line 37
RouteRegistrar namespace(null|string $value)

No description

Parameters

null|string $value

Return Value

RouteRegistrar

at line 37
RouteRegistrar prefix(string $prefix)

No description

Parameters

string $prefix

Return Value

RouteRegistrar

at line 37
RouteRegistrar scopeBindings()

No description

Return Value

RouteRegistrar

at line 37
static void where(array $where)

No description

Parameters

array $where

Return Value

void

at line 37
RouteRegistrar withoutMiddleware(array|string $middleware)

No description

Parameters

array|string $middleware

Return Value

RouteRegistrar

at line 37
RouteRegistrar withoutScopedBindings()

No description

Return Value

RouteRegistrar