This repository was archived by the owner on May 19, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 "email" : " shea.lewis89@gmail.com"
99 }],
1010 "require" : {
11- "illuminate/support" : " 5.7.*"
11+ "illuminate/support" : " 5.7.*|5.8.* "
1212 },
1313 "autoload" : {
1414 "psr-4" : {
Original file line number Diff line number Diff line change 22
33namespace Caffeinated \Shinobi ;
44
5- use Gate ;
6- use Blade ;
5+ use Exception ;
6+ use Illuminate \ Support \ Facades \ Gate ;
77use Caffeinated \Shinobi \Models \Role ;
8+ use Illuminate \Support \Facades \Blade ;
89use Illuminate \Foundation \Application ;
910use Illuminate \Support \Facades \Schema ;
1011use Illuminate \Support \ServiceProvider ;
@@ -53,13 +54,17 @@ public function register()
5354 */
5455 protected function registerGates ()
5556 {
56- if (Schema::hasTable ('permissions ' )) {
57- Shinobi::permission ()->with ('roles ' )->get ()->map (function ($ permission ) {
58- Gate::define ($ permission ->slug , function ($ user ) use ($ permission ) {
59- return $ user ->hasPermissionTo ($ permission );
60- });
61- });
62- }
57+ Gate::before (function ($ user , $ permission ) {
58+ try {
59+ if (method_exists ($ user , 'hasPermissionTo ' )) {
60+ $ permission = Shinobi::permission ()->where ('slug ' , $ permission )->firstOrFail ();
61+
62+ return $ user ->hasPermissionTo ($ permission ) ?: null ;
63+ }
64+ } catch (Exception $ e ) {
65+ //
66+ }
67+ });
6368 }
6469
6570 /**
You can’t perform that action at this time.
0 commit comments