File tree 1 file changed +12
-5
lines changed
1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -50,14 +50,21 @@ public function publishConfig()
50
50
51
51
public function registerBladeDirectives ()
52
52
{
53
- // role
54
- Blade::if ('role ' , function ($ expression ) {
55
- return Auth::guard (config ('acl.guard ' ))->check () && Auth::guard (config ('acl.guard ' ))->user ()->hasRole ($ expression );
53
+ Blade::directive ('role ' , function ($ expression ) {
54
+ return "<?php if (Auth::guard(config('acl.guard'))->check() && Auth::guard(config('acl.guard'))->user()->hasRole( {$ expression })): ?> " ;
55
+ });
56
+
57
+ Blade::directive ('endrole ' , function () {
58
+ return "<?php endif; ?> " ;
56
59
});
57
60
58
61
// permission
59
- Blade::if ('permission ' , function ($ expression ) {
60
- return Auth::guard (config ('acl.guard ' ))->check () && Auth::guard (config ('acl.guard ' ))->user ()->hasPermission ($ expression );
62
+ Blade::directive ('permission ' , function ($ expression ) {
63
+ return "<?php if (Auth::guard(config('acl.guard'))->check() && Auth::guard(config('acl.guard'))->user()->hasPermission( {$ expression })): ?> " ;
64
+ });
65
+
66
+ Blade::directive ('endpermission ' , function () {
67
+ return "<?php endif; ?> " ;
61
68
});
62
69
}
63
70
}
You can’t perform that action at this time.
0 commit comments