Illuminate\Routing\Router::prependMiddlewareToGroup PHP Method

prependMiddlewareToGroup() public method

If the middleware is already in the group, it will not be added again.
public prependMiddlewareToGroup ( string $group, string $middleware )
$group string
$middleware string
    public function prependMiddlewareToGroup($group, $middleware)
    {
        if (isset($this->middlewareGroups[$group]) && !in_array($middleware, $this->middlewareGroups[$group])) {
            array_unshift($this->middlewareGroups[$group], $middleware);
        }
        return $this;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Add a middleware to the beginning of a middleware group.
  * 
  * If the middleware is already in the group, it will not be added again.
  *
  * @param string $group
  * @param string $middleware
  * @return $this 
  * @static 
  */
 public static function prependMiddlewareToGroup($group, $middleware)
 {
     return \Illuminate\Routing\Router::prependMiddlewareToGroup($group, $middleware);
 }