public function using($middleware = [])
    {
        if (! \is_array($middleware)) {
            $middleware = [ $middleware ];
        }

        foreach ($middleware as $callback) {
            $parts = \explode('|', $callback);
            $args = [];

            if (\count($parts) === 2) {
                $args = \explode(',', $parts[1]);
            }

            $action = $this->get_middleware_action($parts[0]);

            $this->middleware[ $action ] = $args;

            // If we are in a nested group, save this level's stack for later removal.
            if ($this->is_group === true) {
                $this->last_middleware[ $action ] = $args;
            }
        }

        return $this;
    }
public function using($middleware = [])
    {
        if (! \is_array($middleware)) {
            $middleware = [ $middleware ];
        }

        foreach ($middleware as $callback) {
            $parts = \explode('|', $callback);
            $args = [];

            if (\count($parts) === 2) {
                $args = \explode(',', $parts[1]);
            }

            $action = $this->get_middleware_action($parts[0]);

            $this->middleware[ $action ] = $args;

            // If we are in a nested group, save this level's stack for later removal.
            if ($this->is_group === true) {
                $this->last_middleware[ $action ] = $args;
            }
        }

        return $this;
    }
public function using ( $ middleware = [ ] ) { if ( ! \ is_array ( $ middleware ) ) { $ middleware = [ $ middleware ] ; } foreach ( $ middleware as $ callback ) { $ parts = \ explode ( '|' , $ callback ) ; $ args = [ ] ; if ( \ count ( $ parts ) === 2 ) { $ args = \ explode ( ',' , $ parts [ 1 ] ) ; } $ action = $ this -> get_middleware_action ( $ parts [ 0 ] ) ; $ this -> middleware [ $ action ] = $ args ; // If we are in a nested group, save this level's stack for later removal. if ( $ this -> is_group === true ) { $ this -> last_middleware [ $ action ] = $ args ; } } return $ this ; }
Apply optional checks to the current route.

These are middleware, executed one after the other allowing the
developer to perform additional checks against the current request.

All passed middleware must return true to be a valid route.

@since 1.0.0

@param  array|string $middleware The middleware hooks to apply to this route.
@return Router
Apply optional checks to the current route .