src/Defender/Providers/DefenderServiceProvider.php
protected function registerBladeExtensions()
    {
        if (false === $this->app['config']->get('defender.template_helpers', true)) {
            return;
        }

        $this->app->afterResolving('blade.compiler', function (BladeCompiler $bladeCompiler) {
            /*
             * add @shield and @endshield to blade compiler
             */
            $bladeCompiler->directive('shield', function ($expression) {
                return "<?php if(app('defender')->canDo({$this->stripParentheses($expression)})): ?>";
            });

            $bladeCompiler->directive('endshield', function ($expression) {
                return '<?php endif; ?>';
            });

            /*
             * add @is and @endis to blade compiler
             */
            $bladeCompiler->directive('is', function ($expression) {
                return "<?php if(app('defender')->hasRoles({$this->stripParentheses($expression)})): ?>";
            });

            $bladeCompiler->directive('endis', function ($expression) {
                return '<?php endif; ?>';
            });

            /*
             * add @isnot and @endisnot to blade compiler
             */
            $bladeCompiler->directive('isnot', function ($expression) {
                return "<?php if(!app('defender')->hasRoles({$this->stripParentheses($expression)})): ?>";
            });

            $bladeCompiler->directive('endisnot', function ($expression) {
                return '<?php endif; ?>';
            });
        });
    }
protected function registerBladeExtensions()
    {
        if (false === $this->app['config']->get('defender.template_helpers', true)) {
            return;
        }

        $this->app->afterResolving('blade.compiler', function (BladeCompiler $bladeCompiler) {
            /*
             * add @shield and @endshield to blade compiler
             */
            $bladeCompiler->directive('shield', function ($expression) {
                return "<?php if(app('defender')->canDo({$this->stripParentheses($expression)})): ?>";
            });

            $bladeCompiler->directive('endshield', function ($expression) {
                return '<?php endif; ?>';
            });

            /*
             * add @is and @endis to blade compiler
             */
            $bladeCompiler->directive('is', function ($expression) {
                return "<?php if(app('defender')->hasRoles({$this->stripParentheses($expression)})): ?>";
            });

            $bladeCompiler->directive('endis', function ($expression) {
                return '<?php endif; ?>';
            });

            /*
             * add @isnot and @endisnot to blade compiler
             */
            $bladeCompiler->directive('isnot', function ($expression) {
                return "<?php if(!app('defender')->hasRoles({$this->stripParentheses($expression)})): ?>";
            });

            $bladeCompiler->directive('endisnot', function ($expression) {
                return '<?php endif; ?>';
            });
        });
    }
protected function registerBladeExtensions ( ) { if ( false === $ this -> app [ 'config' ] -> get ( 'defender.template_helpers' , true ) ) { return ; } $ this -> app -> afterResolving ( 'blade.compiler' , function ( BladeCompiler $ bladeCompiler ) { /*
             * add @shield and @endshield to blade compiler
             */ $ bladeCompiler -> directive ( 'shield' , function ( $ expression ) { return "<?php if(app('defender')->canDo({$this->stripParentheses($expression)})): ?>" ; } ) ; $ bladeCompiler -> directive ( 'endshield' , function ( $ expression ) { return '<?php endif; ?>' ; } ) ; /*
             * add @is and @endis to blade compiler
             */ $ bladeCompiler -> directive ( 'is' , function ( $ expression ) { return "<?php if(app('defender')->hasRoles({$this->stripParentheses($expression)})): ?>" ; } ) ; $ bladeCompiler -> directive ( 'endis' , function ( $ expression ) { return '<?php endif; ?>' ; } ) ; /*
             * add @isnot and @endisnot to blade compiler
             */ $ bladeCompiler -> directive ( 'isnot' , function ( $ expression ) { return "<?php if(!app('defender')->hasRoles({$this->stripParentheses($expression)})): ?>" ; } ) ; $ bladeCompiler -> directive ( 'endisnot' , function ( $ expression ) { return '<?php endif; ?>' ; } ) ; } ) ; }
Register new blade extensions.
Register new blade extensions .