Skip to content

Commit ed33cf5

Browse files
Defer registering permissions on the Gate instance until it's resolved (#104)
* perf: avoid provisioning the gate on app boot if it's not used. * fix: import the interface - embarrassing * V2.0 (#105) * ⬆️ Support for laravel 6 * remove travis ci * update changelog Co-authored-by: Mostafa Abd El-Salam Maklad <dev.mostafa.maklad@gmail.com>
1 parent e0b16d1 commit ed33cf5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/PermissionServiceProvider.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Maklad\Permission;
44

5+
use Illuminate\Contracts\Auth\Access\Gate;
56
use Illuminate\Support\ServiceProvider;
67
use Illuminate\View\Compilers\BladeCompiler;
78
use Maklad\Permission\Contracts\PermissionInterface as Permission;
@@ -14,7 +15,7 @@
1415
*/
1516
class PermissionServiceProvider extends ServiceProvider
1617
{
17-
public function boot(PermissionRegistrar $permissionLoader)
18+
public function boot()
1819
{
1920
$helpers = new Helpers();
2021
if ($helpers->isNotLumen()) {
@@ -40,7 +41,9 @@ public function boot(PermissionRegistrar $permissionLoader)
4041

4142
$this->registerModelBindings();
4243

43-
$permissionLoader->registerPermissions();
44+
$this->app->afterResolving(Gate::class, function(){
45+
app(PermissionRegistrar::class)->registerPermissions();
46+
});
4447
}
4548

4649
public function register()

0 commit comments

Comments
 (0)