@@ 52-56 (lines=5) @@ | ||
49 | protected function registerBladeExtensions() |
|
50 | { |
|
51 | $this->app->afterResolving('blade.compiler', function (BladeCompiler $bladeCompiler) { |
|
52 | $bladeCompiler->directive('role', function ($arguments) { |
|
53 | list($role, $guard) = explode(',', $arguments.','); |
|
54 | ||
55 | return "<?php if(auth({$guard})->check() && auth({$guard})->user()->hasRole({$role})): ?>"; |
|
56 | }); |
|
57 | $bladeCompiler->directive('endrole', function () { |
|
58 | return '<?php endif; ?>'; |
|
59 | }); |
|
@@ 61-65 (lines=5) @@ | ||
58 | return '<?php endif; ?>'; |
|
59 | }); |
|
60 | ||
61 | $bladeCompiler->directive('hasrole', function ($arguments) { |
|
62 | list($role, $guard) = explode(',', $arguments.','); |
|
63 | ||
64 | return "<?php if(auth({$guard})->check() && auth({$guard})->user()->hasRole({$role})): ?>"; |
|
65 | }); |
|
66 | $bladeCompiler->directive('endhasrole', function () { |
|
67 | return '<?php endif; ?>'; |
|
68 | }); |