Skip to content

Commit a0eae25

Browse files
committed
Update README.md
1 parent e129481 commit a0eae25

File tree

1 file changed

+39
-14
lines changed

1 file changed

+39
-14
lines changed

README.md

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -214,24 +214,24 @@ The permission expiration feature allows you to set temporary access that expire
214214

215215
1. **Assign Permission with Expiration**: Use the `givePermissionsTo` method to assign a permission with an expiration date.
216216

217-
```php
218-
// Assign a permission with a specific expiration date
219-
$user->givePermissionsTo(['post-create', 'post-edit'],
220-
Carbon::now()->addDays(30), // Each Permission expiration assign in 30 days
221-
);
222-
```
217+
```php
218+
// Assign a permission with a specific expiration date
219+
$user->givePermissionsTo(['post-create', 'post-edit'],
220+
Carbon::now()->addDays(30), // Each Permission expiration assign in 30 days
221+
);
222+
```
223223

224-
In this example, the `post-create` permission will be assigned to the user and expire after 30 days.
224+
In this example, the `post-create` permission will be assigned to the user and expire after 30 days.
225225

226226
2. **Assign Multiple Permissions with Different Expirations**: If you need to assign multiple permissions with individual expiration dates, pass an associative array where the keys are permission names, and the values are the expiration dates.
227227

228-
```php
229-
$user->givePermissionsTo(['post-create', 'post-edit'],
230-
[
231-
Carbon::now()->addDays(10), // Expires in 10 days
232-
Carbon::now()->addHours(6), // Expires in 6 hours
233-
]);
234-
```
228+
```php
229+
$user->givePermissionsTo(['post-create', 'post-edit'],
230+
[
231+
Carbon::now()->addDays(10), // Expires in 10 days
232+
Carbon::now()->addHours(6), // Expires in 6 hours
233+
]);
234+
```
235235

236236

237237
## How to Use without Permissions Expiration
@@ -252,6 +252,31 @@ OR
252252
$user->givePermissionsTo(['post-create', 'post-edit']);
253253
```
254254

255+
## Detach Permissions from a User
256+
257+
The `detachPermissions` method allows you to remove one or multiple permissions from a user. You can specify permissions as an array, a pipe-separated string, a comma-separated string, or a single permission name.
258+
259+
### Example Usage
260+
261+
```php
262+
$user = auth()->user();
263+
264+
// Detach multiple permissions using an array
265+
$user->detachPermissions(['post-create', 'post-edit']);
266+
267+
// Detach multiple permissions using a pipe-separated string
268+
$user->detachPermissions('post-create|post-edit');
269+
270+
// Detach multiple permissions using a comma-separated string
271+
$user->detachPermissions('post-create,post-edit');
272+
273+
// Detach a single permission
274+
$user->detachPermissions('post-create');
275+
```
276+
277+
### Notes
278+
- Ensure that the permissions you are detaching exist and are assigned to the user.
279+
- This method is flexible and accepts different formats for specifying permissions.
255280

256281
### Checking for Expired Permissions OR without Permissions Expiration
257282

0 commit comments

Comments
 (0)