app\Models\Access\User\Traits\UserAccess::attachRole PHP Method

attachRole() public method

Alias to eloquent many-to-many relation's attach() method.
public attachRole ( mixed $role ) : void
$role mixed
return void
    public function attachRole($role)
    {
        if (is_object($role)) {
            $role = $role->getKey();
        }
        if (is_array($role)) {
            $role = $role['id'];
        }
        $this->roles()->attach($role);
    }