src/Conductors/SyncsRolesAndAbilities.php
protected function syncAbilities($abilities, $options = ['forbidden' => false])
    {
        $abilityKeys = $this->getAbilityIds($abilities);
        $authority = $this->getAuthority();
        $relation = $authority->abilities();

        $this->newPivotQuery($relation)
             ->where('entity_type', $authority->getMorphClass())
             ->whereNotIn($this->getRelatedPivotKeyName($relation), $abilityKeys)
             ->where('forbidden', $options['forbidden'])
             ->delete();

        if ($options['forbidden']) {
            (new ForbidsAbilities($this->authority))->to($abilityKeys);
        } else {
            (new GivesAbilities($this->authority))->to($abilityKeys);
        }
    }
protected function syncAbilities($abilities, $options = ['forbidden' => false])
    {
        $abilityKeys = $this->getAbilityIds($abilities);
        $authority = $this->getAuthority();
        $relation = $authority->abilities();

        $this->newPivotQuery($relation)
             ->where('entity_type', $authority->getMorphClass())
             ->whereNotIn($this->getRelatedPivotKeyName($relation), $abilityKeys)
             ->where('forbidden', $options['forbidden'])
             ->delete();

        if ($options['forbidden']) {
            (new ForbidsAbilities($this->authority))->to($abilityKeys);
        } else {
            (new GivesAbilities($this->authority))->to($abilityKeys);
        }
    }
protected function syncAbilities ( $ abilities , $ options = [ 'forbidden' => false ] ) { $ abilityKeys = $ this -> getAbilityIds ( $ abilities ) ; $ authority = $ this -> getAuthority ( ) ; $ relation = $ authority -> abilities ( ) ; $ this -> newPivotQuery ( $ relation ) -> where ( 'entity_type' , $ authority -> getMorphClass ( ) ) -> whereNotIn ( $ this -> getRelatedPivotKeyName ( $ relation ) , $ abilityKeys ) -> where ( 'forbidden' , $ options [ 'forbidden' ] ) -> delete ( ) ; if ( $ options [ 'forbidden' ] ) { ( new ForbidsAbilities ( $ this -> authority ) ) -> to ( $ abilityKeys ) ; } else { ( new GivesAbilities ( $ this -> authority ) ) -> to ( $ abilityKeys ) ; } }
Sync the given abilities for the authority.

@param  iterable  $abilities
@param  array  $options
@return void
Sync the given abilities for the authority .