Skip to content

Commit 7a2587b

Browse files
author
Mateus Junges
committed
Update docs for v2.0.2
1 parent ee395b8 commit 7a2587b

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,26 @@ one instance of permission model and a permission slug too.
199199
//With permission slugs:
200200
$user->assignPermissions('permission-slug-1', 'permission-slug-2');
201201

202+
//Using arrays:
203+
$user->assignPermissions(['permission-slug-1', 'permission-slug-2']);
204+
202205
//With permission ids:
203206
$user->assignPermissions(1, 2, 3);
204207

208+
//Using arrays:
209+
$user->assignPermissions([1, 2, 3]);
210+
205211
//With instances of permission model:
206212
$user->assignPermissions(Permission::find(1), Permission::find(2));
207213

214+
//Using arrays:
215+
$user->assignPermissions([Permission::find(1), Permission::find(2)]);
216+
208217
//With the three ways above combined:
209218
$user->assignPermissions(1, 'permission-slug', Permission::find(1));
219+
220+
//Using arrays:
221+
$user->assignPermissions([1, 'permission-slug', Permission::find(1)]);
210222
```
211223
Like as add permissions to user, you can add permissions to groups.
212224
To do this, you have the same method, and they can be used by the same way:
@@ -215,14 +227,26 @@ To do this, you have the same method, and they can be used by the same way:
215227
//With permission slugs:
216228
$group->assignPermissions('permission-slug-1', 'permission-slug-2');
217229

230+
//Using arrays:
231+
$group->assignPermissions(['permission-slug-1', 'permission-slug-2']);
232+
218233
//With permission ids:
219234
$group->assignPermissions(1, 2, 3);
220235

236+
//Using arrays:
237+
$group->assignPermissions([1, 2, 3]);
238+
221239
//With instances of permission model:
222240
$group->assignPermissions(Permission::find(1), Permission::find(2));
223241

242+
//Using arrays:
243+
$group->assignPermissions([Permission::find(1), Permission::find(2)]);
244+
224245
//With the three ways above combined:
225246
$group->assignPermissions(1, 'permission-slug', Permission::find(1));
247+
248+
//Using arrays:
249+
$group->assignPermissions([1, 'permission-slug', Permission::find(1)]);
226250
```
227251

228252
After add permissions to a group, you may want/need to add a user to a group.
@@ -234,36 +258,63 @@ You can add a group to a user, and use 4 different types of parameters:
234258
//Assign a group to a user, using group slugs:
235259
$user->assignGroup('group-slug-1', 'group-slug-2');
236260

261+
//Using arrays:
262+
$user->assignGroup(['group-slug-1', 'group-slug-2']);
263+
237264
//Assign a group to a user, using group ids:
238265
$user->assignGroup(1, 2, 3);
239266

267+
//Using arrays:
268+
$user->assignGroup([1, 2, 3]);
269+
240270
//Assign a group to a user, with instance of group models:
241271
$user->assignGroup(Group::find(1), Group::find(2));
242272

273+
//Using arrays:
274+
$user->assignGroup([Group::find(1), Group::find(2)]);
275+
243276
//Assign group to a user, combining the three methods above:
244277
$user->assignGroup(Group::find(1), 'group-slug-2', 3);
278+
279+
//Usign arrays:
280+
$user->assignGroup([Group::find(1), 'group-slug-2', 3]);
245281
```
246282
#### Second way:
247283
You can add a user to a group, and use 4 different types of parameters:
248284
```php
249285
//Assign a user to a group, with user names:
250286
$group->assignUser('User one', 'User two');
251287

288+
//Using arrays:
289+
$group->assignUser(['User one', 'User two']);
290+
252291
//Assign a user to a group, user ids:
253292
$group->assignUser(1, 2, 3);
254293

294+
//Using arrays:
295+
$group->assignUser([1, 2, 3]);
296+
255297
//Assign a user to a group, with instance of User models:
256298
$group->assignUser(User::find(1), User::find(2));
257299

300+
//Using arrays:
301+
$group->assignUser([User::find(1), User::find(2)]);
302+
258303
//Assign a user to a group combining the three methods above:
259304
$group->assignUser(User::find(1), 'User name', 3);
305+
306+
//Using arrays:
307+
$group->assignUser([User::find(1), 'User name', 3]);
260308
```
261309

262310
### Revoke permissions
263311
#### 1 - Revoke permissions from user
264312
You can revoke a user permission using the method below:
265313
```php
266314
$user->revokePermissions('permission-slug', 2, Permission::find(3));
315+
316+
//Or with arrays:
317+
$user->revokePermissions(['permission-slug', 2, Permission::find(3)]);
267318
```
268319
Like the methods to add or remove a group from a user, you can use as function parameter a
269320
the permission ids, permission slugs, instance of permission model, or,
@@ -273,6 +324,9 @@ combine these three ways.
273324
You can revoke a group permission using the method below:
274325
```php
275326
$group->revokePermissions('permission-slug', 2, Permission::find(3));
327+
328+
//Or with arrays:
329+
$group->revokePermissions(['permission-slug', 2, Permission::find(3)]);
276330
```
277331
Like the methods to add or remove a group from a user, you can use as function parameter
278332
the permission ids, permission slugs, instance of permission model, or,
@@ -283,6 +337,10 @@ You can remove a group from the user by using one of these methods:
283337
```php
284338
$user->revokeGroup('permission-slug', 2, Permission::find(3));
285339
$group->removeUser('User name', 2, User::find(3));
340+
341+
//Or with arrays:
342+
$user->revokeGroup(['permission-slug', 2, Permission::find(3)]);
343+
$group->removeUser(['User name', 2, User::find(3)]);
286344
```
287345
Like the methods to add or remove a group from a user, you can use as function parameter a
288346
group/user ids, group/user slugs, instance of group/user model , or,
@@ -399,14 +457,26 @@ The user permissions can synced with this method:
399457
//With permission id:
400458
$user->syncPermissions(1, 2, 4);
401459

460+
//Using array:
461+
$user->syncPermissions([1, 2, 4]);
462+
402463
//With permission slugs:
403464
$user->syncPermissions('permission-slug-1', 'permission-slug-2');
404465

466+
//Using arrays:
467+
$user->syncPermissions(['permission-slug-1', 'permission-slug-2']);
468+
405469
//With instance of permission model:
406470
$user->syncPermissions(Permission::find(1), Permission::find(2));
407471

472+
//Using arrays:
473+
$user->syncPermissions([Permission::find(1), Permission::find(2)]);
474+
408475
//Combining the three ways:
409476
$user->syncPermissions(1, 'permission-slug', Permission::find(3));
477+
478+
//Using arrays:
479+
$user->syncPermissions([1, 'permission-slug', Permission::find(3)]);
410480
```
411481

412482
## Syncing group permissions
@@ -415,14 +485,26 @@ The groups permissions can synced with this method:
415485
//With permission id:
416486
$group->syncPermissions(1, 2, 4);
417487

488+
//Usign arrays:
489+
$group->syncPermissions([1, 2, 4]);
490+
418491
//With permission slugs:
419492
$group->syncPermissions('permission-slug-1', 'permission-slug-2');
420493

494+
//Using arrays:
495+
$group->syncPermissions(['permission-slug-1', 'permission-slug-2']);
496+
421497
//With instance of permission model:
422498
$group->syncPermissions(Permission::find(1), Permission::find(2));
423499

500+
//Using arrays:
501+
$group->syncPermissions([Permission::find(1), Permission::find(2)]);
502+
424503
//Combining the three ways:
425504
$group->syncPermissions(1, 'permission-slug', Permission::find(3));
505+
506+
//Using arrays:
507+
$group->syncPermissions([1, 'permission-slug', Permission::find(3)]);
426508
```
427509

428510
## Some "shortcuts"

0 commit comments

Comments
 (0)