protected function setForeignAttributesForCreate(Model $model)
    {
        $foreignKey = $this->getForeignKeyName();
        $parentKeyValue = $this->getParentKey();
        if (is_array($foreignKey)) { //Check for multi-columns relationship
            foreach ($foreignKey as $index => $key) {
                $model->setAttribute($key, $parentKeyValue[$index]);
            }
        } else {
            parent::setForeignAttributesForCreate($model);
        }
    }
protected function setForeignAttributesForCreate(Model $model)
    {
        $foreignKey = $this->getForeignKeyName();
        $parentKeyValue = $this->getParentKey();
        if (is_array($foreignKey)) { //Check for multi-columns relationship
            foreach ($foreignKey as $index => $key) {
                $model->setAttribute($key, $parentKeyValue[$index]);
            }
        } else {
            parent::setForeignAttributesForCreate($model);
        }
    }
protected function setForeignAttributesForCreate ( Model $ model ) { $ foreignKey = $ this -> getForeignKeyName ( ) ; $ parentKeyValue = $ this -> getParentKey ( ) ; if ( is_array ( $ foreignKey ) ) { //Check for multi-columns relationship foreach ( $ foreignKey as $ index => $ key ) { $ model -> setAttribute ( $ key , $ parentKeyValue [ $ index ] ) ; } } else { parent :: setForeignAttributesForCreate ( $ model ) ; } }
Set the foreign ID for creating a related model.

@param  \Illuminate\Database\Eloquent\Model  $model
@return void
Set the foreign ID for creating a related model .