File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 55use AuroraWebSoftware \AAuth \Commands \AAuthCommand ;
66use Illuminate \Support \Facades \Auth ;
77use Illuminate \Support \Facades \Blade ;
8+ use Illuminate \Support \Facades \Gate ;
89use Illuminate \Support \Facades \Session ;
910use Spatie \LaravelPackageTools \Package ;
1011use Spatie \LaravelPackageTools \PackageServiceProvider ;
@@ -52,6 +53,10 @@ public function boot(): void
5253 );
5354 });
5455
56+ Gate::before (function ($ user , $ ability , $ arguments = []) {
57+ return app ('aauth ' )->can ($ ability ) ?: null ;
58+ });
59+
5560 Blade::directive ('aauth ' , function ($ permission ) {
5661 return "<?php if(\AuroraWebSoftware\AAuth\Facades\AAuth::can( $ permission)){ ?> " ;
5762 });
Original file line number Diff line number Diff line change @@ -71,4 +71,23 @@ public function getDeletableAttribute(): bool
7171 // todo new syntax
7272 return $ this ->getAssignedUserCountAttribute () == 0 ;
7373 }
74+
75+ public function can ($ abilities , $ arguments = []): bool
76+ {
77+ if (is_string ($ abilities )) {
78+ return app ('aauth ' )->can ($ abilities );
79+ }
80+
81+ if (is_array ($ abilities )) {
82+ foreach ($ abilities as $ ability ) {
83+ if (! app ('aauth ' )->can ($ ability )) {
84+ return false ;
85+ }
86+ }
87+
88+ return true ;
89+ }
90+
91+ return parent ::can ($ abilities , $ arguments );
92+ }
7493}
You can’t perform that action at this time.
0 commit comments