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