protected function protectMethods()
    {
        $request = $this->request;

        // available methods for resources.
        $resources = $this->crud['resources'];

        // protection methods being passed in a route.
        $methods = $this->getAction('protect_methods');

        // get method being called on controller.
        $caller = $this->parseMethod();

        // determine if we use resource or restful http method to protect crud.
        $called = in_array($caller, $resources) ? $caller : $request->method();

        // if controller is a resource or closure
        // and does not have methods like
        // UserController@index but only
        // UserController we use crud restful.
        $methods = is_array($methods) ? $methods :
            (in_array($caller, $resources) ?
                $this->crud['resource'] : $this->crud['restful']);

        // determine crud method we're trying to protect
        $crud = $this->filterMethods($methods, function ($k, $v) use ($called) {
            return in_array($called, $v);
        });

        // crud method is read, view, delete etc
        // match it against our permissions
        // view.user or delete.user
        // multiple keys like create,store?
        // use OR operator and join keys with alias.
        $permission = implode('|', array_map(function ($e) {
            return $e . '.' . $this->parseAlias();
        }, array_keys($crud)));

        return ! $this->forbiddenRoute() && $request->user()->can($permission);
    }
protected function protectMethods()
    {
        $request = $this->request;

        // available methods for resources.
        $resources = $this->crud['resources'];

        // protection methods being passed in a route.
        $methods = $this->getAction('protect_methods');

        // get method being called on controller.
        $caller = $this->parseMethod();

        // determine if we use resource or restful http method to protect crud.
        $called = in_array($caller, $resources) ? $caller : $request->method();

        // if controller is a resource or closure
        // and does not have methods like
        // UserController@index but only
        // UserController we use crud restful.
        $methods = is_array($methods) ? $methods :
            (in_array($caller, $resources) ?
                $this->crud['resource'] : $this->crud['restful']);

        // determine crud method we're trying to protect
        $crud = $this->filterMethods($methods, function ($k, $v) use ($called) {
            return in_array($called, $v);
        });

        // crud method is read, view, delete etc
        // match it against our permissions
        // view.user or delete.user
        // multiple keys like create,store?
        // use OR operator and join keys with alias.
        $permission = implode('|', array_map(function ($e) {
            return $e . '.' . $this->parseAlias();
        }, array_keys($crud)));

        return ! $this->forbiddenRoute() && $request->user()->can($permission);
    }
protected function protectMethods ( ) { $ request = $ this -> request ; // available methods for resources. $ resources = $ this -> crud [ 'resources' ] ; // protection methods being passed in a route. $ methods = $ this -> getAction ( 'protect_methods' ) ; // get method being called on controller. $ caller = $ this -> parseMethod ( ) ; // determine if we use resource or restful http method to protect crud. $ called = in_array ( $ caller , $ resources ) ? $ caller : $ request -> method ( ) ; // if controller is a resource or closure // and does not have methods like // UserController@index but only // UserController we use crud restful. $ methods = is_array ( $ methods ) ? $ methods : ( in_array ( $ caller , $ resources ) ? $ this -> crud [ 'resource' ] : $ this -> crud [ 'restful' ] ) ; // determine crud method we're trying to protect $ crud = $ this -> filterMethods ( $ methods , function ( $ k , $ v ) use ( $ called ) { return in_array ( $ called , $ v ) ; } ) ; // crud method is read, view, delete etc // match it against our permissions // view.user or delete.user // multiple keys like create,store? // use OR operator and join keys with alias. $ permission = implode ( '|' , array_map ( function ( $ e ) { return $ e . '.' . $ this -> parseAlias ( ) ; } , array_keys ( $ crud ) ) ) ; return ! $ this -> forbiddenRoute ( ) && $ request -> user ( ) -> can ( $ permission ) ; }
Protect Crud functions of controller.

@return string
Protect Crud functions of controller .