protected function setPivotPopulator(BelongsToMany $relation)
    {
        $relatedClass = get_class($relation->getRelated());

        // If the many-to-many related model has not yet been added,
        // the pivot table will be populated along with it if it will be added.
        if (!$this->populator->wasAdded($relatedClass)) {
            return;
        }

        $this->pivotPopulators[$relatedClass] = new PivotPopulator(
            $this,
            $relation,
            $this->generator
        );
    }