src/Conductors/AssignsRoles.php
protected function assignRoles(Collection $roles, $authorityClass, Collection $authorityIds)
    {
        $roleIds = $roles->map(function ($model) {
            return $model->getKey();
        });

        $morphType = (new $authorityClass)->getMorphClass();

        $records = $this->buildAttachRecords($roleIds, $morphType, $authorityIds);

        $existing = $this->getExistingAttachRecords($roleIds, $morphType, $authorityIds);

        $this->createMissingAssignRecords($records, $existing);
    }
protected function assignRoles(Collection $roles, $authorityClass, Collection $authorityIds)
    {
        $roleIds = $roles->map(function ($model) {
            return $model->getKey();
        });

        $morphType = (new $authorityClass)->getMorphClass();

        $records = $this->buildAttachRecords($roleIds, $morphType, $authorityIds);

        $existing = $this->getExistingAttachRecords($roleIds, $morphType, $authorityIds);

        $this->createMissingAssignRecords($records, $existing);
    }
protected function assignRoles ( Collection $ roles , $ authorityClass , Collection $ authorityIds ) { $ roleIds = $ roles -> map ( function ( $ model ) { return $ model -> getKey ( ) ; } ) ; $ morphType = ( new $ authorityClass ) -> getMorphClass ( ) ; $ records = $ this -> buildAttachRecords ( $ roleIds , $ morphType , $ authorityIds ) ; $ existing = $ this -> getExistingAttachRecords ( $ roleIds , $ morphType , $ authorityIds ) ; $ this -> createMissingAssignRecords ( $ records , $ existing ) ; }
Assign the given roles to the given authorities.

@param  \Illuminate\Suuport\Collection  $roles
@param  string $authorityClass
@param  \Illuminate\Suuport\Collection  $authorityIds
@return void
Assign the given roles to the given authorities .