master

laravel/framework

Last updated at: 29/12/2023 09:25

Route.php

TLDR

The Route.php file in the Illuminate\Support\Facades namespace provides a facade for the Router class. It allows for convenient access to routing functionality in Laravel.

Methods

get

Defines a GET route.

post

Defines a POST route.

put

Defines a PUT route.

patch

Defines a PATCH route.

delete

Defines a DELETE route.

options

Defines an OPTIONS route.

any

Defines a route that handles all HTTP verbs.

fallback

Defines a fallback route.

redirect

Defines a route that redirects to a different URI.

permanentRedirect

Defines a route that performs a permanent redirect.

view

Defines a route that returns a view.

match

Defines a route that matches specific HTTP methods.

resources

Registers a group of resource routes.

resource

Registers a single resource route.

apiResources

Registers a group of API resource routes.

apiResource

Registers a single API resource route.

singletons

Registers a group of singleton routes.

singleton

Registers a single singleton route.

apiSingletons

Registers a group of API singleton routes.

apiSingleton

Registers a single API singleton route.

group

Creates a route group for adding shared attributes and middleware.

mergeWithLastGroup

Merges the given attributes with the previous route group.

getLastGroupPrefix

Gets the prefix of the last route group.

addRoute

Adds a route to the route collection.

newRoute

Creates a new route.

respondWithRoute

Generates a response for a route with the given name.

dispatch

Dispatches a request and returns a response.

dispatchToRoute

Dispatches a request to a specific route.

gatherRouteMiddleware

Gathers the middleware for a route.

resolveMiddleware

Resolves the middleware for a route.

prepareResponse

Prepares a response for sending.

toResponse

Converts the given value to a response.

substituteBindings

Substitutes route bindings in a route.

substituteImplicitBindings

Substitutes implicit route bindings in a route.

substituteImplicitBindingsUsing

Sets the callback for substituting implicit route bindings.

matched

Registers a callback to be called after a route is matched.

getMiddleware

Gets the middleware for the application.

aliasMiddleware

Aliases a middleware class with a custom name.

hasMiddlewareGroup

Checks if a middleware group exists.

getMiddlewareGroups

Gets all of the defined middleware groups.

middlewareGroup

Defines a middleware group.

prependMiddlewareToGroup

Adds middleware to the beginning of a group.

pushMiddlewareToGroup

Adds middleware to the end of a group.

removeMiddlewareFromGroup

Removes middleware from a group.

flushMiddlewareGroups

Flushes all of the defined middleware groups.

bind

Binds a route parameter to a binder callback.

model

Binds a route resource to a model class.

getBindingCallback

Gets the resolving callback for a binding.

getPatterns

Gets the route pattern definitions.

pattern

Adds a pattern definition for a route variable.

patterns

Adds multiple pattern definitions for route variables.

hasGroupStack

Checks if there is a route group stack.

getGroupStack

Gets the route group stack.

input

Gets the input value for a parameter.

getCurrentRequest

Gets the current request.

getCurrentRoute

Gets the current route.

current

Alias for getCurrentRoute.

has

Checks if a route matches the given name or names.

currentRouteName

Gets the name of the current route.

is

Checks if the current request matches a given pattern or patterns.

currentRouteNamed

Checks if the current route matches a given name or names.

currentRouteAction

Gets the action name of the current route.

uses

Checks if the current route uses a given action or actions.

currentRouteUses

Checks if the current route uses a given action.

singularResourceParameters

Sets whether to use singular resource parameters.

resourceParameters

Sets the resource parameters.

resourceVerbs

Sets the resource verbs.

getRoutes

Gets the route collection.

setRoutes

Sets the route collection.

setCompiledRoutes

Sets the compiled routes.

uniqueMiddleware

Makes the given middleware list unique.

setContainer

Sets the dependency injection container.

macro

Adds a new macro.

mixin

Adds a mixin to the router.

hasMacro

Checks if a macro exists.

flushMacros

Flushes all of the router's macros.

macroCall

Calls the registered macro for a method.

attribute

Sets an attribute for the route.

whereAlpha

Adds pattern filters for alpha characters.

whereAlphaNumeric

Adds pattern filters for alphanumeric characters.

whereNumber

Adds pattern filters for numeric characters.

whereUlid

Adds pattern filters for ULID values.

whereUuid

Adds pattern filters for UUID values.

whereIn

Adds pattern filters for values that are within a given array.

as

Sets the name for the route.

controller

Sets the controller for the route.

domain

Sets the domain for the route.

middleware

Adds middleware to the route.

missing

Sets a closure to be called when a route is not found.

name

Sets the name for the route.

namespace

Sets the namespace for the route.

prefix

Sets the prefix for the route.

scopeBindings

Scopes the bindings.

where

Adds where constraints to the route.

withoutMiddleware

Excludes middleware from the route.

withoutScopedBindings

Excludes scoped bindings from the route.

Classes

None

<?php

namespace Illuminate\Support\Facades;

/**
 * @method static \Illuminate\Routing\Route get(string $uri, array|string|callable|null $action = null)
 * @method static \Illuminate\Routing\Route post(string $uri, array|string|callable|null $action = null)
 * @method static \Illuminate\Routing\Route put(string $uri, array|string|callable|null $action = null)
 * @method static \Illuminate\Routing\Route patch(string $uri, array|string|callable|null $action = null)
 * @method static \Illuminate\Routing\Route delete(string $uri, array|string|callable|null $action = null)
 * @method static \Illuminate\Routing\Route options(string $uri, array|string|callable|null $action = null)
 * @method static \Illuminate\Routing\Route any(string $uri, array|string|callable|null $action = null)
 * @method static \Illuminate\Routing\Route fallback(array|string|callable|null $action)
 * @method static \Illuminate\Routing\Route redirect(string $uri, string $destination, int $status = 302)
 * @method static \Illuminate\Routing\Route permanentRedirect(string $uri, string $destination)
 * @method static \Illuminate\Routing\Route view(string $uri, string $view, array $data = [], int|array $status = 200, array $headers = [])
 * @method static \Illuminate\Routing\Route match(array|string $methods, string $uri, array|string|callable|null $action = null)
 * @method static void resources(array $resources, array $options = [])
 * @method static \Illuminate\Routing\PendingResourceRegistration resource(string $name, string $controller, array $options = [])
 * @method static void apiResources(array $resources, array $options = [])
 * @method static \Illuminate\Routing\PendingResourceRegistration apiResource(string $name, string $controller, array $options = [])
 * @method static void singletons(array $singletons, array $options = [])
 * @method static \Illuminate\Routing\PendingSingletonResourceRegistration singleton(string $name, string $controller, array $options = [])
 * @method static void apiSingletons(array $singletons, array $options = [])
 * @method static \Illuminate\Routing\PendingSingletonResourceRegistration apiSingleton(string $name, string $controller, array $options = [])
 * @method static \Illuminate\Routing\Router group(array $attributes, \Closure|array|string $routes)
 * @method static array mergeWithLastGroup(array $new, bool $prependExistingPrefix = true)
 * @method static string getLastGroupPrefix()
 * @method static \Illuminate\Routing\Route addRoute(array|string $methods, string $uri, array|string|callable|null $action)
 * @method static \Illuminate\Routing\Route newRoute(array|string $methods, string $uri, mixed $action)
 * @method static \Symfony\Component\HttpFoundation\Response respondWithRoute(string $name)
 * @method static \Symfony\Component\HttpFoundation\Response dispatch(\Illuminate\Http\Request $request)
 * @method static \Symfony\Component\HttpFoundation\Response dispatchToRoute(\Illuminate\Http\Request $request)
 * @method static array gatherRouteMiddleware(\Illuminate\Routing\Route $route)
 * @method static array resolveMiddleware(array $middleware, array $excluded = [])
 * @method static \Symfony\Component\HttpFoundation\Response prepareResponse(\Symfony\Component\HttpFoundation\Request $request, mixed $response)
 * @method static \Symfony\Component\HttpFoundation\Response toResponse(\Symfony\Component\HttpFoundation\Request $request, mixed $response)
 * @method static \Illuminate\Routing\Route substituteBindings(\Illuminate\Routing\Route $route)
 * @method static void substituteImplicitBindings(\Illuminate\Routing\Route $route)
 * @method static \Illuminate\Routing\Router substituteImplicitBindingsUsing(callable $callback)
 * @method static void matched(string|callable $callback)
 * @method static array getMiddleware()
 * @method static \Illuminate\Routing\Router aliasMiddleware(string $name, string $class)
 * @method static bool hasMiddlewareGroup(string $name)
 * @method static array getMiddlewareGroups()
 * @method static \Illuminate\Routing\Router middlewareGroup(string $name, array $middleware)
 * @method static \Illuminate\Routing\Router prependMiddlewareToGroup(string $group, string $middleware)
 * @method static \Illuminate\Routing\Router pushMiddlewareToGroup(string $group, string $middleware)
 * @method static \Illuminate\Routing\Router removeMiddlewareFromGroup(string $group, string $middleware)
 * @method static \Illuminate\Routing\Router flushMiddlewareGroups()
 * @method static void bind(string $key, string|callable $binder)
 * @method static void model(string $key, string $class, \Closure|null $callback = null)
 * @method static \Closure|null getBindingCallback(string $key)
 * @method static array getPatterns()
 * @method static void pattern(string $key, string $pattern)
 * @method static void patterns(array $patterns)
 * @method static bool hasGroupStack()
 * @method static array getGroupStack()
 * @method static mixed input(string $key, string|null $default = null)
 * @method static \Illuminate\Http\Request getCurrentRequest()
 * @method static \Illuminate\Routing\Route|null getCurrentRoute()
 * @method static \Illuminate\Routing\Route|null current()
 * @method static bool has(string|array $name)
 * @method static string|null currentRouteName()
 * @method static bool is(mixed ...$patterns)
 * @method static bool currentRouteNamed(mixed ...$patterns)
 * @method static string|null currentRouteAction()
 * @method static bool uses(array ...$patterns)
 * @method static bool currentRouteUses(string $action)
 * @method static void singularResourceParameters(bool $singular = true)
 * @method static void resourceParameters(array $parameters = [])
 * @method static array|null resourceVerbs(array $verbs = [])
 * @method static \Illuminate\Routing\RouteCollectionInterface getRoutes()
 * @method static void setRoutes(\Illuminate\Routing\RouteCollection $routes)
 * @method static void setCompiledRoutes(array $routes)
 * @method static array uniqueMiddleware(array $middleware)
 * @method static \Illuminate\Routing\Router setContainer(\Illuminate\Container\Container $container)
 * @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()
 * @method static mixed macroCall(string $method, array $parameters)
 * @method static \Illuminate\Routing\RouteRegistrar attribute(string $key, mixed $value)
 * @method static \Illuminate\Routing\RouteRegistrar whereAlpha(array|string $parameters)
 * @method static \Illuminate\Routing\RouteRegistrar whereAlphaNumeric(array|string $parameters)
 * @method static \Illuminate\Routing\RouteRegistrar whereNumber(array|string $parameters)
 * @method static \Illuminate\Routing\RouteRegistrar whereUlid(array|string $parameters)
 * @method static \Illuminate\Routing\RouteRegistrar whereUuid(array|string $parameters)
 * @method static \Illuminate\Routing\RouteRegistrar whereIn(array|string $parameters, array $values)
 * @method static \Illuminate\Routing\RouteRegistrar as(string $value)
 * @method static \Illuminate\Routing\RouteRegistrar controller(string $controller)
 * @method static \Illuminate\Routing\RouteRegistrar domain(string $value)
 * @method static \Illuminate\Routing\RouteRegistrar middleware(array|string|null $middleware)
 * @method static \Illuminate\Routing\RouteRegistrar missing(\Closure $missing)
 * @method static \Illuminate\Routing\RouteRegistrar name(string $value)
 * @method static \Illuminate\Routing\RouteRegistrar namespace(string|null $value)
 * @method static \Illuminate\Routing\RouteRegistrar prefix(string $prefix)
 * @method static \Illuminate\Routing\RouteRegistrar scopeBindings()
 * @method static \Illuminate\Routing\RouteRegistrar where(array $where)
 * @method static \Illuminate\Routing\RouteRegistrar withoutMiddleware(array|string $middleware)
 * @method static \Illuminate\Routing\RouteRegistrar withoutScopedBindings()
 *
 * @see \Illuminate\Routing\Router
 */
class Route extends Facade
{
    /**
     * Get the registered name of the component.
     *
     * @return string
     */
    protected static function getFacadeAccessor()
    {
        return 'router';
    }
}