Skip to content

Commit 34a5737

Browse files
committed
Move super-admin before check to main policy instead of service provider
1 parent aca32a0 commit 34a5737

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Policies/LaravelGovernorPolicy.php

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ public function __construct()
1111
$this->permissions = Permission::with('role')->get();
1212
}
1313

14+
public function before($user, $ability)
15+
{
16+
return $user->isSuperAdmin;
17+
}
18+
1419
protected function validatePermissions($user, $action, $entity, $entityCreatorId)
1520
{
1621
if (! $user->roles) {

src/Providers/LaravelGovernorServiceProvider.php

-4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ public function boot(GateContract $gate)
3434

3535
Event::listen('eloquent.creating: *', CreatingListener::class);
3636

37-
$gate->before(function ($user, $ability) {
38-
return $user->isSuperAdmin;
39-
});
40-
4137
$this->publishes([__DIR__ . '/../../config/config.php' => config_path('genealabs-laravel-governor.php')], 'genealabs-laravel-governor');
4238
$this->publishes([__DIR__ . '/../../public' => public_path('genealabs-laravel-governor')], 'genealabs-laravel-governor');
4339
$this->loadViewsFrom(__DIR__ . '/../../resources/views', 'genealabs-laravel-governor');

0 commit comments

Comments
 (0)