public function update($id, array $attributes)
{
$user = $this->findById($id);
$user->first_name = $attributes['first_name'];
$user->last_name = $attributes['last_name'];
$user->email = $attributes['email'];
$user->permissions = $attributes['permissions'];
if (array_key_exists('password', $attributes)) {
$user->password = $attributes['password'];
}
$user->save();
if (array_key_exists('groups', $attributes)) {
$this->syncGroups($attributes['groups'], $user);
}
$this->event->fire('users.update', array($user));
return $user;
}