|
8 | 8 | - [Authorizing Users](#authorizing-users) |
9 | 9 | - [can()](#can) |
10 | 10 | - [inGroup()](#ingroup) |
| 11 | + - [hasPermission()](#haspermission) |
11 | 12 | - [Managing User Permissions](#managing-user-permissions) |
12 | 13 | - [addPermission()](#addpermission) |
13 | 14 | - [removePermission()](#removepermission) |
14 | 15 | - [syncPermissions()](#syncpermissions) |
| 16 | + - [getPermissions()](#getpermissions) |
15 | 17 | - [Managing User Groups](#managing-user-groups) |
16 | 18 | - [addGroup()](#addgroup) |
17 | 19 | - [removeGroup()](#removegroup) |
18 | 20 | - [syncGroups()](#syncgroups) |
| 21 | + - [getGroups()](#getgroups) |
19 | 22 |
|
20 | 23 | Authorization happens once a user has been identified through authentication. It is the process of |
21 | 24 | determining what actions a user is allowed to do within your site. |
@@ -115,6 +118,16 @@ if (! $user->inGroup('superadmin', 'admin')) { |
115 | 118 | } |
116 | 119 | ``` |
117 | 120 |
|
| 121 | +#### hasPermission() |
| 122 | + |
| 123 | +Checks to see if the user has the permission set directly on themselves. This disregards any groups they are part of. |
| 124 | + |
| 125 | +```php |
| 126 | +if (! $user->hasPermission('users.create')) { |
| 127 | + // |
| 128 | +} |
| 129 | +``` |
| 130 | + |
118 | 131 | ## Managing User Permissions |
119 | 132 |
|
120 | 133 | Permissions can be granted on a user level as well as on a group level. Any user-level permissions granted will |
@@ -147,6 +160,14 @@ not in this list will be removed. |
147 | 160 | $user->syncPermissions('admin.access', 'beta.access'); |
148 | 161 | ``` |
149 | 162 |
|
| 163 | +#### getPermissions() |
| 164 | + |
| 165 | +Returns all permissions this user has assigned directly to them. |
| 166 | + |
| 167 | +```php |
| 168 | +$user->getPermissions(); |
| 169 | +``` |
| 170 | + |
150 | 171 | ## Managing User Groups |
151 | 172 |
|
152 | 173 | #### addGroup() |
@@ -175,3 +196,11 @@ not in this list will be removed. |
175 | 196 | ```php |
176 | 197 | $user->syncGroups('admin', 'beta'); |
177 | 198 | ``` |
| 199 | + |
| 200 | +#### getGroups() |
| 201 | + |
| 202 | +Returns all groups this user is a part of. |
| 203 | + |
| 204 | +```php |
| 205 | +$user->getGroups(); |
| 206 | +``` |
0 commit comments