protected function registerRoutes()
    {
        $http = Arr::get($this->triggers, 'http');
        if (is_null($http)) {
            return;
        }

        // Validar
        try {
            Validator::validate($http, ['route' => 'required', 'methods' => 'required', 'function' => 'required']);
        } catch (ExceptionAttrs $e) {
            throw new \Exception($e->toMessageStr());
        }

        // Validar função
        $function = $http['function'];
        if (! array_key_exists($function, $this->functions)) {
            throw new \Exception(sprintf('Function %s not found', $function));
        }

        $class = $this->functions[$function];
        $methods = explode(',', Arr::get($http, 'methods', 'get'));

        foreach ($methods as $method) {
            // Validar metodo
            if (! in_array($method, ['get', 'post', 'delete', 'put'])) {
                throw new \Exception(sprintf('Method %s invalid', $method));
            }

            $args = [];
            $args['prefix'] = $this->getName();
            $args['uses'] = sprintf('%s@execute', $class);
            $args['middleware'] = 'api';
            call_user_func_array([router(), $method], [$http['route'], $args]);
        }
    }
protected function registerRoutes()
    {
        $http = Arr::get($this->triggers, 'http');
        if (is_null($http)) {
            return;
        }

        // Validar
        try {
            Validator::validate($http, ['route' => 'required', 'methods' => 'required', 'function' => 'required']);
        } catch (ExceptionAttrs $e) {
            throw new \Exception($e->toMessageStr());
        }

        // Validar função
        $function = $http['function'];
        if (! array_key_exists($function, $this->functions)) {
            throw new \Exception(sprintf('Function %s not found', $function));
        }

        $class = $this->functions[$function];
        $methods = explode(',', Arr::get($http, 'methods', 'get'));

        foreach ($methods as $method) {
            // Validar metodo
            if (! in_array($method, ['get', 'post', 'delete', 'put'])) {
                throw new \Exception(sprintf('Method %s invalid', $method));
            }

            $args = [];
            $args['prefix'] = $this->getName();
            $args['uses'] = sprintf('%s@execute', $class);
            $args['middleware'] = 'api';
            call_user_func_array([router(), $method], [$http['route'], $args]);
        }
    }
protected function registerRoutes ( ) { $ http = Arr :: get ( $ this -> triggers , 'http' ) ; if ( is_null ( $ http ) ) { return ; } // Validar try { Validator :: validate ( $ http , [ 'route' => 'required' , 'methods' => 'required' , 'function' => 'required' ] ) ; } catch ( ExceptionAttrs $ e ) { throw new \ Exception ( $ e -> toMessageStr ( ) ) ; } // Validar função $ function = $ http [ 'function' ] ; if ( ! array_key_exists ( $ function , $ this -> functions ) ) { throw new \ Exception ( sprintf ( 'Function %s not found' , $ function ) ) ; } $ class = $ this -> functions [ $ function ] ; $ methods = explode ( ',' , Arr :: get ( $ http , 'methods' , 'get' ) ) ; foreach ( $ methods as $ method ) { // Validar metodo if ( ! in_array ( $ method , [ 'get' , 'post' , 'delete' , 'put' ] ) ) { throw new \ Exception ( sprintf ( 'Method %s invalid' , $ method ) ) ; } $ args = [ ] ; $ args [ 'prefix' ] = $ this -> getName ( ) ; $ args [ 'uses' ] = sprintf ( '%s@execute' , $ class ) ; $ args [ 'middleware' ] = 'api' ; call_user_func_array ( [ router ( ) , $ method ] , [ $ http [ 'route' ] , $ args ] ) ; } }
Registrar rotas.
Registrar rotas .