Skip to content

Commit

Permalink
Gate notes
Browse files Browse the repository at this point in the history
  • Loading branch information
drbyte authored Aug 30, 2024
1 parent 0068a21 commit 36bb367
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions docs/basic-usage/direct-permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ HOWEVER, If you have reason to directly assign individual permissions to specifi

## Direct Permissions to Users

### Giving/Revoking direct permissions

A permission can be given to any user:

```php
Expand All @@ -37,6 +39,15 @@ Or revoke & add new permissions in one go:
$user->syncPermissions(['edit articles', 'delete articles']);
```

## Checking Direct Permissions
Like all permissions assigned via roles, you can check if a user has a permission by using Laravel's default `can` function. This will also allow you to use Super-Admin features provided by Laravel's Gate:

```php
$user->can('edit articles');
```

NOTE: The following `hasPermissionTo`, `hasAnyPermission`, `hasAllPermissions` functions do not support Super-Admin functionality. Use `can`, `canAny`, `canAll` instead.

You can check if a user has a permission:

```php
Expand Down Expand Up @@ -68,9 +79,3 @@ You may also pass integers to lookup by permission id
```php
$user->hasAnyPermission(['edit articles', 1, 5]);
```

Like all permissions assigned via roles, you can check if a user has a permission by using Laravel's default `can` function:

```php
$user->can('edit articles');
```

0 comments on commit 36bb367

Please sign in to comment.