src/Conductors/SyncsRolesAndAbilities.php
protected function sync(array $ids, BelongsToMany $relation)
    {
        $current = $this->pluck(
            $this->newPivotQuery($relation),
            $this->getRelatedPivotKeyName($relation)
        );

        $this->detach(array_diff($current, $ids), $relation);

        $relation->attach(
            array_diff($ids, $current),
            Models::scope()->getAttachAttributes($this->authority)
        );
    }
protected function sync(array $ids, BelongsToMany $relation)
    {
        $current = $this->pluck(
            $this->newPivotQuery($relation),
            $this->getRelatedPivotKeyName($relation)
        );

        $this->detach(array_diff($current, $ids), $relation);

        $relation->attach(
            array_diff($ids, $current),
            Models::scope()->getAttachAttributes($this->authority)
        );
    }
protected function sync ( array $ ids , BelongsToMany $ relation ) { $ current = $ this -> pluck ( $ this -> newPivotQuery ( $ relation ) , $ this -> getRelatedPivotKeyName ( $ relation ) ) ; $ this -> detach ( array_diff ( $ current , $ ids ) , $ relation ) ; $ relation -> attach ( array_diff ( $ ids , $ current ) , Models :: scope ( ) -> getAttachAttributes ( $ this -> authority ) ) ; }
Sync the given IDs on the pivot relation.

This is a heavily-modified version of Eloquent's built-in
BelongsToMany@sync - which we sadly cannot use because
our scope sets a "closure where" on the pivot table.

@param  array  $ids
@param  \Illuminate\Database\Eloquent\Relations\BelongsToMany  $relation
@return void
Sync the given IDs on the pivot relation .