public function execute(Model $currentParent, array $insertedPKs)
    {
        if (!isset($insertedPKs[$this->relatedClass])) {
            return;
        }

        $this->updateParentKey($currentParent);

        $this->relation->attach(
            collect($this->pickRelatedIds($insertedPKs))
                ->mapWithKeys(function ($relatedId) use ($insertedPKs, $currentParent) {
                    return [$relatedId => $this->getExtraAttributes($insertedPKs, $currentParent)];
                })
                ->all()
        );
    }
public function execute(Model $currentParent, array $insertedPKs)
    {
        if (!isset($insertedPKs[$this->relatedClass])) {
            return;
        }

        $this->updateParentKey($currentParent);

        $this->relation->attach(
            collect($this->pickRelatedIds($insertedPKs))
                ->mapWithKeys(function ($relatedId) use ($insertedPKs, $currentParent) {
                    return [$relatedId => $this->getExtraAttributes($insertedPKs, $currentParent)];
                })
                ->all()
        );
    }
public function execute ( Model $ currentParent , array $ insertedPKs ) { if ( ! isset ( $ insertedPKs [ $ this -> relatedClass ] ) ) { return ; } $ this -> updateParentKey ( $ currentParent ) ; $ this -> relation -> attach ( collect ( $ this -> pickRelatedIds ( $ insertedPKs ) ) -> mapWithKeys ( function ( $ relatedId ) use ( $ insertedPKs , $ currentParent ) { return [ $ relatedId => $ this -> getExtraAttributes ( $ insertedPKs , $ currentParent ) ] ; } ) -> all ( ) ) ; }
Populate the pivot table.

@param  Model   $currentParent
@param  array[] $insertedPKs
@return void
Populate the pivot table .