コード例 #1
0
 /**
  * Attach or detach permission on a given role.
  *
  * @param int $roleId       Role Id
  * @param int $permissionId Permission Id
  *
  * @return void
  */
 public function assignPermission($roleId, $permissionId)
 {
     $role = Role::findOrFail($roleId);
     $role->permissions()->toggle($permissionId);
 }
コード例 #2
0
 /**
  * Assign a role to the entity.
  *
  * @param string $role Role name
  *
  * @return mixed
  */
 public function assignRole($role)
 {
     return $this->roles()->save(Role::where($role)->firstOrFail());
 }