Skip to content

Commit 839b774

Browse files
authored
Update super-admin.md
As a first time reader of the package documentation (which by the way is really good!), I realized that in the seeding example we use 'super-admin'. I haven't tried it yet, but I believe these two should be consistent to work, so I propose we change it here to super-admin as well.
1 parent 231530a commit 839b774

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/basic-usage/super-admin.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Then you can implement the best-practice of primarily using permission-based con
99

1010

1111
## `Gate::before`
12-
If you want a "Super Admin" role to respond `true` to all permissions, without needing to assign all those permissions to a role, you can use [Laravel's `Gate::before()` method](https://laravel.com/docs/master/authorization#intercepting-gate-checks). For example:
12+
If you want a "super-admin" role to respond `true` to all permissions, without needing to assign all those permissions to a role, you can use [Laravel's `Gate::before()` method](https://laravel.com/docs/master/authorization#intercepting-gate-checks). For example:
1313

1414
In Laravel 11 this would go in the `boot()` method of `AppServiceProvider`:
1515
In Laravel 10 and below it would go in the `boot()` method of `AuthServiceProvider.php`:
@@ -18,10 +18,10 @@ use Illuminate\Support\Facades\Gate;
1818
// ...
1919
public function boot()
2020
{
21-
// Implicitly grant "Super Admin" role all permissions
21+
// Implicitly grant "super-admin" role all permissions
2222
// This works in the app by using gate-related functions like auth()->user->can() and @can()
2323
Gate::before(function ($user, $ability) {
24-
return $user->hasRole('Super Admin') ? true : null;
24+
return $user->hasRole('super-admin') ? true : null;
2525
});
2626
}
2727
```
@@ -44,7 +44,7 @@ use App\Models\User; // could be any Authorizable model
4444
*/
4545
public function before(User $user, string $ability): bool|null
4646
{
47-
if ($user->hasRole('Super Admin')) {
47+
if ($user->hasRole('super-admin')) {
4848
return true;
4949
}
5050

@@ -62,6 +62,6 @@ The following code snippet is inspired from [Freek's blog article](https://freek
6262
// somewhere in a service provider
6363

6464
Gate::after(function ($user, $ability) {
65-
return $user->hasRole('Super Admin'); // note this returns boolean
65+
return $user->hasRole('super-admin'); // note this returns boolean
6666
});
6767
```

0 commit comments

Comments
 (0)