@@ -199,14 +199,26 @@ one instance of permission model and a permission slug too.
199
199
//With permission slugs:
200
200
$user->assignPermissions('permission-slug-1', 'permission-slug-2');
201
201
202
+ //Using arrays:
203
+ $user->assignPermissions(['permission-slug-1', 'permission-slug-2']);
204
+
202
205
//With permission ids:
203
206
$user->assignPermissions(1, 2, 3);
204
207
208
+ //Using arrays:
209
+ $user->assignPermissions([1, 2, 3]);
210
+
205
211
//With instances of permission model:
206
212
$user->assignPermissions(Permission::find(1), Permission::find(2));
207
213
214
+ //Using arrays:
215
+ $user->assignPermissions([Permission::find(1), Permission::find(2)]);
216
+
208
217
//With the three ways above combined:
209
218
$user->assignPermissions(1, 'permission-slug', Permission::find(1));
219
+
220
+ //Using arrays:
221
+ $user->assignPermissions([1, 'permission-slug', Permission::find(1)]);
210
222
```
211
223
Like as add permissions to user, you can add permissions to groups.
212
224
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:
215
227
//With permission slugs:
216
228
$group->assignPermissions('permission-slug-1', 'permission-slug-2');
217
229
230
+ //Using arrays:
231
+ $group->assignPermissions(['permission-slug-1', 'permission-slug-2']);
232
+
218
233
//With permission ids:
219
234
$group->assignPermissions(1, 2, 3);
220
235
236
+ //Using arrays:
237
+ $group->assignPermissions([1, 2, 3]);
238
+
221
239
//With instances of permission model:
222
240
$group->assignPermissions(Permission::find(1), Permission::find(2));
223
241
242
+ //Using arrays:
243
+ $group->assignPermissions([Permission::find(1), Permission::find(2)]);
244
+
224
245
//With the three ways above combined:
225
246
$group->assignPermissions(1, 'permission-slug', Permission::find(1));
247
+
248
+ //Using arrays:
249
+ $group->assignPermissions([1, 'permission-slug', Permission::find(1)]);
226
250
```
227
251
228
252
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:
234
258
//Assign a group to a user, using group slugs:
235
259
$user->assignGroup('group-slug-1', 'group-slug-2');
236
260
261
+ //Using arrays:
262
+ $user->assignGroup(['group-slug-1', 'group-slug-2']);
263
+
237
264
//Assign a group to a user, using group ids:
238
265
$user->assignGroup(1, 2, 3);
239
266
267
+ //Using arrays:
268
+ $user->assignGroup([1, 2, 3]);
269
+
240
270
//Assign a group to a user, with instance of group models:
241
271
$user->assignGroup(Group::find(1), Group::find(2));
242
272
273
+ //Using arrays:
274
+ $user->assignGroup([Group::find(1), Group::find(2)]);
275
+
243
276
//Assign group to a user, combining the three methods above:
244
277
$user->assignGroup(Group::find(1), 'group-slug-2', 3);
278
+
279
+ //Usign arrays:
280
+ $user->assignGroup([Group::find(1), 'group-slug-2', 3]);
245
281
```
246
282
#### Second way:
247
283
You can add a user to a group, and use 4 different types of parameters:
248
284
``` php
249
285
//Assign a user to a group, with user names:
250
286
$group->assignUser('User one', 'User two');
251
287
288
+ //Using arrays:
289
+ $group->assignUser(['User one', 'User two']);
290
+
252
291
//Assign a user to a group, user ids:
253
292
$group->assignUser(1, 2, 3);
254
293
294
+ //Using arrays:
295
+ $group->assignUser([1, 2, 3]);
296
+
255
297
//Assign a user to a group, with instance of User models:
256
298
$group->assignUser(User::find(1), User::find(2));
257
299
300
+ //Using arrays:
301
+ $group->assignUser([User::find(1), User::find(2)]);
302
+
258
303
//Assign a user to a group combining the three methods above:
259
304
$group->assignUser(User::find(1), 'User name', 3);
305
+
306
+ //Using arrays:
307
+ $group->assignUser([User::find(1), 'User name', 3]);
260
308
```
261
309
262
310
### Revoke permissions
263
311
#### 1 - Revoke permissions from user
264
312
You can revoke a user permission using the method below:
265
313
``` php
266
314
$user->revokePermissions('permission-slug', 2, Permission::find(3));
315
+
316
+ //Or with arrays:
317
+ $user->revokePermissions(['permission-slug', 2, Permission::find(3)]);
267
318
```
268
319
Like the methods to add or remove a group from a user, you can use as function parameter a
269
320
the permission ids, permission slugs, instance of permission model, or,
@@ -273,6 +324,9 @@ combine these three ways.
273
324
You can revoke a group permission using the method below:
274
325
``` php
275
326
$group->revokePermissions('permission-slug', 2, Permission::find(3));
327
+
328
+ //Or with arrays:
329
+ $group->revokePermissions(['permission-slug', 2, Permission::find(3)]);
276
330
```
277
331
Like the methods to add or remove a group from a user, you can use as function parameter
278
332
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:
283
337
``` php
284
338
$user->revokeGroup('permission-slug', 2, Permission::find(3));
285
339
$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)]);
286
344
```
287
345
Like the methods to add or remove a group from a user, you can use as function parameter a
288
346
group/user ids, group/user slugs, instance of group/user model , or,
@@ -399,14 +457,26 @@ The user permissions can synced with this method:
399
457
//With permission id:
400
458
$user->syncPermissions(1, 2, 4);
401
459
460
+ //Using array:
461
+ $user->syncPermissions([1, 2, 4]);
462
+
402
463
//With permission slugs:
403
464
$user->syncPermissions('permission-slug-1', 'permission-slug-2');
404
465
466
+ //Using arrays:
467
+ $user->syncPermissions(['permission-slug-1', 'permission-slug-2']);
468
+
405
469
//With instance of permission model:
406
470
$user->syncPermissions(Permission::find(1), Permission::find(2));
407
471
472
+ //Using arrays:
473
+ $user->syncPermissions([Permission::find(1), Permission::find(2)]);
474
+
408
475
//Combining the three ways:
409
476
$user->syncPermissions(1, 'permission-slug', Permission::find(3));
477
+
478
+ //Using arrays:
479
+ $user->syncPermissions([1, 'permission-slug', Permission::find(3)]);
410
480
```
411
481
412
482
## Syncing group permissions
@@ -415,14 +485,26 @@ The groups permissions can synced with this method:
415
485
//With permission id:
416
486
$group->syncPermissions(1, 2, 4);
417
487
488
+ //Usign arrays:
489
+ $group->syncPermissions([1, 2, 4]);
490
+
418
491
//With permission slugs:
419
492
$group->syncPermissions('permission-slug-1', 'permission-slug-2');
420
493
494
+ //Using arrays:
495
+ $group->syncPermissions(['permission-slug-1', 'permission-slug-2']);
496
+
421
497
//With instance of permission model:
422
498
$group->syncPermissions(Permission::find(1), Permission::find(2));
423
499
500
+ //Using arrays:
501
+ $group->syncPermissions([Permission::find(1), Permission::find(2)]);
502
+
424
503
//Combining the three ways:
425
504
$group->syncPermissions(1, 'permission-slug', Permission::find(3));
505
+
506
+ //Using arrays:
507
+ $group->syncPermissions([1, 'permission-slug', Permission::find(3)]);
426
508
```
427
509
428
510
## Some "shortcuts"
0 commit comments