laravel-acl: Call to undefined method Illuminate\View\Compilers\BladeCompiler::directive()

This error appeared after doing composer update today, currently running Laravel 5.0.33.

I managed to find the block of code at fault, lines 64 to 81 in AclServiceProvider.php, as copied below. Commenting it out temporarily fixed the problem but I’m unsure about a permanent solution (not even sure why this has suddenly appeared).

        // role
        Blade::directive('role', function($expression) {
            return "<?php if (Auth::check() && Auth::user()->is{$expression}): ?>";
        });

        Blade::directive('endrole', function() {
            return "<?php endif; ?>";
        });

        // permission
        Blade::directive('permission', function($expression) {
            return "<?php if (Auth::check() && Auth::user()->can{$expression}): ?>";
        });

        Blade::directive('endpermission', function() {
            return "<?php endif; ?>";
        });

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

update “zizaco/entrust”: “dev-laravel-5” to “zizaco/entrust”: “1.4.1”

Solve my problem.