-
Notifications
You must be signed in to change notification settings - Fork 217
Assign Permissions to Role
Kodeine edited this page Feb 23, 2015
·
1 revision
Lets assign created permissions to a Role.
Note: You can pass an object, an array, role->id or just name.
$roleAdmin = Role::first(); // administrator
// permission as an object
$roleAdmin->assignPermission($permUser);
// as an id
$roleAdmin->assignPermission($permUser->id);
// or by name
$roleAdmin->assignPermission('user');
Or multiple permissions
at once:
// multiple permissions in an array
$roleAdmin->assignPermission(array($permUser, $permPost->id));
// or mutiple role slugs separated by comma or pipe.
$roleAdmin->assignPermission('user, 'post');
Note: The system will throw an exception if permission does not exists.