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, callable|array|string|null $action = null)

Register a new route with the given verbs.

$this
metadata(array $metadata)

No description

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

Register a new route with the router.

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

Compile the action into an array including the attributes.

static void
flushState()

Flush all static state.

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

No description

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

No description

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

No description

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

No description

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

No description

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

No description

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

No description

query(string $uri, callable|array|string|null $action = 'null')

No description

$this
as(string $value)

No description

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

No description

$this
controller(string $controller)

No description

$this
domain(BackedEnum|string $value)

No description

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

No description

$this
missing(Closure $missing)

No description

$this
name(BackedEnum|string $value)

No description

$this
namespace(null|string $value)

No description

$this
port(int $port)

No description

$this
prefix(string $prefix)

No description

$this
scopeBindings()

No description

$this
where(array $where)

No description

$this
withoutMiddleware(array|string $middleware)

No description

$this
withoutScopedBindings()

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 288
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 103
__construct(Router $router)

Create a new route registrar instance.

Parameters

Router $router

at line 113
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 163
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 171
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 179
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 187
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 195
RouteRegistrar group(Closure|array|string $callback)

Create a route group with shared attributes.

Parameters

Closure|array|string $callback

Return Value

RouteRegistrar

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

Register a new route with the given verbs.

Parameters

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

Return Value

Route

at line 41
$this metadata(array $metadata)

No description

Parameters

array $metadata

Return Value

$this

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

Register a new route with the router.

Parameters

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

Return Value

Route

at line 233
protected array compileAction(callable|array|string|null $action)

Compile the action into an array including the attributes.

Parameters

callable|array|string|null $action

Return Value

array

at line 276
static void flushState()

Flush all static state.

Return Value

void

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

No description

Parameters

string $uri
callable|array|string|null $action

Return Value

Route

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

No description

Parameters

string $uri
callable|array|string|null $action

Return Value

Route

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

No description

Parameters

string $uri
callable|array|string|null $action

Return Value

Route

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

No description

Parameters

string $uri
callable|array|string|null $action

Return Value

Route

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

No description

Parameters

string $uri
callable|array|string|null $action

Return Value

Route

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

No description

Parameters

string $uri
callable|array|string|null $action

Return Value

Route

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

No description

Parameters

string $uri
callable|array|string|null $action

Return Value

Route

at line 41
Route query(string $uri, callable|array|string|null $action = 'null')

No description

Parameters

string $uri
callable|array|string|null $action

Return Value

Route

at line 41
$this as(string $value)

No description

Parameters

string $value

Return Value

$this

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

No description

Parameters

UnitEnum|string $ability
array|string $models

Return Value

$this

at line 41
$this controller(string $controller)

No description

Parameters

string $controller

Return Value

$this

at line 41
$this domain(BackedEnum|string $value)

No description

Parameters

BackedEnum|string $value

Return Value

$this

at line 41
$this middleware(null|array|string $middleware)

No description

Parameters

null|array|string $middleware

Return Value

$this

at line 41
$this missing(Closure $missing)

No description

Parameters

Closure $missing

Return Value

$this

at line 41
$this name(BackedEnum|string $value)

No description

Parameters

BackedEnum|string $value

Return Value

$this

at line 41
$this namespace(null|string $value)

No description

Parameters

null|string $value

Return Value

$this

at line 41
$this port(int $port)

No description

Parameters

int $port

Return Value

$this

at line 41
$this prefix(string $prefix)

No description

Parameters

string $prefix

Return Value

$this

at line 41
$this scopeBindings()

No description

Return Value

$this

at line 41
$this where(array $where)

No description

Parameters

array $where

Return Value

$this

at line 41
$this withoutMiddleware(array|string $middleware)

No description

Parameters

array|string $middleware

Return Value

$this

at line 41
$this withoutScopedBindings()

No description

Return Value

$this