Skip to content
Kodeine edited this page Feb 23, 2015 · 1 revision

Sync Role(s) To User

You can pass an array of role objects,ids or slugs to sync them to a user.

$user->syncRoles([1,2,3]);
$user->syncRoles('administrator, moderator');
$user->syncRoles((array($roleAdmin, $roleModerator));

Note: The system will throw an exception if role does not exists.