public function attachRole($role, $group = null)
{
if (is_object($role)) {
$role = $role->getKey();
}
if (is_array($role)) {
$role = $role['id'];
}
if (!is_object($group) && $group != null) {
throw new InvalidArgumentException();
}
if (!is_null($group)) {
$group = $group->getKey();
}
$this->roles()->wherePivot(Config::get('laratrust.group_foreign_key'), $group)->detach($role);
$this->roles()->attach($role, [Config::get('laratrust.group_foreign_key') => $group]);
$this->flushCache();
return $this;
}