roles
roles copied to clipboard
Duplicate roles being added with attachRoles
/**
* Attach role to a user.
*
* @param int|\HttpOz\Roles\Models\Role $role
*
* @return bool
*/
public function attachRole( $role ) {
if ( ! collect( $this->getRoles() )->contains( $role ) ) {
$this->clearCached();
$this->roles()->attach( $role );
}
return true;
}
Should prevent duplicate roles, however:
User::find(1)->getRoles()->contains(Role::find(1)) => true collect(User::find(1)->getRoles())->contains(Role::find(1)) => false
Seems that collect is breaking this.