Skip to content

Commit

Permalink
Update README.md (#201)
Browse files Browse the repository at this point in the history
Add code example for adding policies to service provider
  • Loading branch information
ritechoice23 authored Sep 21, 2024
1 parent a51671e commit c438d4e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,20 @@ php artisan permissions:sync -O|--oep
```

### Role and Permission Policies

Create a RolePolicy and PermissionPolicy if you wish to control the visibility of the resources on the navigation menu.
Make sure to add them to the AuthServiceProvider.
> **ℹ️ Info:** *Laravel 11 removed `AuthServiceProvider`, so in this case we need to use `AppServiceProvider` instead.*
Make sure to add them to the AuthServiceProvider.
> **ℹ️ Info:** *Laravel 11 removed `AuthServiceProvider`, so, in this case, we need to use `AppServiceProvider` instead.*
```bash
use App\Policies\RolePolicy;
use App\Policies\PermissionPolicy;
use Spatie\Permission\Models\Role;
use Spatie\Permission\Models\Permission;

Gate::policy(Role::class, RolePolicy::class);
Gate::policy(Permission::class, PermissionPolicy::class);
```

### Ignoring prompts
You can ignore any prompts by add the flag ``-Y`` or ``--yes-to-all``
Expand Down

0 comments on commit c438d4e

Please sign in to comment.