1313
1414class PermissionServiceProvider extends ServiceProvider
1515{
16- public function boot ()
16+ public function boot (PermissionRegistrar $ permissionLoader )
1717 {
1818 $ this ->offerPublishing ();
1919
@@ -23,14 +23,14 @@ public function boot()
2323
2424 $ this ->registerModelBindings ();
2525
26- $ this ->callAfterResolving (PermissionRegistrar::class, function (PermissionRegistrar $ permissionLoader ) {
27- if ($ this ->app ->config ['permission.register_permission_check_method ' ]) {
28- $ permissionLoader ->clearClassPermissions ();
29- $ permissionLoader ->registerPermissions ();
30- }
31- });
26+ if ($ this ->app ->config ['permission.register_permission_check_method ' ]) {
27+ $ permissionLoader ->clearClassPermissions ();
28+ $ permissionLoader ->registerPermissions ();
29+ }
3230
33- $ this ->app ->singleton (PermissionRegistrar::class);
31+ $ this ->app ->singleton (PermissionRegistrar::class, function ($ app ) use ($ permissionLoader ) {
32+ return $ permissionLoader ;
33+ });
3434 }
3535
3636 public function register ()
@@ -74,16 +74,14 @@ protected function registerCommands()
7474
7575 protected function registerModelBindings ()
7676 {
77- $ this ->app ->bind (PermissionContract::class, function ($ app ) {
78- $ config = $ app ->config ['permission.models ' ];
77+ $ config = $ this ->app ->config ['permission.models ' ];
7978
80- return $ app ->make ($ config ['permission ' ]);
81- });
82- $ this ->app ->bind (RoleContract::class, function ($ app ) {
83- $ config = $ app ->config ['permission.models ' ];
79+ if (! $ config ) {
80+ return ;
81+ }
8482
85- return $ app ->make ( $ config ['role ' ]);
86- } );
83+ $ this -> app ->bind (PermissionContract::class, $ config ['permission ' ]);
84+ $ this -> app -> bind (RoleContract::class, $ config [ ' role ' ] );
8785 }
8886
8987 public static function bladeMethodWrapper ($ method , $ role , $ guard = null )
0 commit comments