Skip to content

Commit e233070

Browse files
committed
Use variadic passing of groups/permissions
1 parent e41b531 commit e233070

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

docs/quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ This will add all new permissions. You can also sync permissions so that the use
193193
```php
194194
$user = auth()->user();
195195

196-
$user->syncPermissions(['users.create', 'beta.access']);
196+
$user->syncPermissions('users.create', 'beta.access');
197197
```
198198

199199
## Check If a User Has Permission

src/Authorization/Traits/Authorizable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function removeGroup(string ...$groups): self
8080
*
8181
* @return $this
8282
*/
83-
public function syncGroups(array $groups): self
83+
public function syncGroups(...$groups): self
8484
{
8585
$this->populateGroups();
8686

@@ -189,7 +189,7 @@ public function removePermission(string ...$permissions): self
189189
*
190190
* @return $this
191191
*/
192-
public function syncPermissions(array $permissions): self
192+
public function syncPermissions(...$permissions): self
193193
{
194194
$this->populatePermissions();
195195

tests/Authorization/AuthorizableTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function testSyncGroups(): void
142142
'created_at' => Time::now()->toDateTimeString(),
143143
]);
144144

145-
$this->user->syncGroups(['admin', 'beta']);
145+
$this->user->syncGroups('admin', 'beta');
146146
$this->assertSame(['admin', 'beta'], $this->user->getGroups());
147147
$this->seeInDatabase('auth_groups_users', [
148148
'user_id' => $this->user->id,
@@ -263,7 +263,7 @@ public function testSyncPermissions(): void
263263
'created_at' => Time::now()->toDateTimeString(),
264264
]);
265265

266-
$this->user->syncPermissions(['admin.access', 'beta.access']);
266+
$this->user->syncPermissions('admin.access', 'beta.access');
267267
$this->assertSame(['admin.access', 'beta.access'], $this->user->getPermissions());
268268
$this->seeInDatabase('auth_permissions_users', [
269269
'user_id' => $this->user->id,

0 commit comments

Comments
 (0)