Supercharge of sync Many2Many function.
Original sync doesn't insert NULL ids.

@param $fighters
331516
public function syncTeams($fighters)
    {
        $this->teams()->detach();
        foreach ($fighters as $fighter) {
            if ($fighter != null) {
                $this->teams()->attach($fighter);
            } else {
                // Insert row manually
                DB::table('fighters_group_team')->insertGetId(
                    ['team_id' => null, 'fighters_group_id' => $this->id]
                );
            }
        }
    }
592027
protected function addMany(array $arguments = [])
    {
        foreach ($arguments as $name => $options) {
            $this->add($name, $options);
        }
    }
158447
protected function pushGroups($numRounds, $numFightersElim)
    {
        for ($roundNumber = 2; $roundNumber <= $numRounds; $roundNumber++) {
            // From last match to first match
            $maxMatches = ($numFightersElim / pow(2, $roundNumber));
            for ($matchNumber = 1; $matchNumber <= $maxMatches; $matchNumber++) {
                $fighters = $this->createByeGroup(2);
                $group = $this->saveGroup($matchNumber, $roundNumber, null);
                $this->syncGroup($group, $fighters);
            }
        }
    }
321932
protected function synchronize(string $relation)
    {
        $actualContent = $this->relationships[$relation];

        $relationshipObject = $this->entityMap->$relation($this->getEntityObject());
        $relationshipObject->setParent($this->wrappedEntity);
        $relationshipObject->sync($actualContent);
    }
1235715
public function mergeValuesBase(array $values): void
  {
    if (array_key_exists($this->name, $values))
    {
      $this->setValuesBase($values);
    }
  }
8415
protected function synchronizeIncludes(array $includes): void
	{
		foreach($includes as $include) {
			$rowToAdd = $this->createRow($include);
			Helpers::appendToFile($this->configurationFile, $rowToAdd);
		}
	}
173572
public function setTenantsAttribute($tenants): void
    {
        static::saved(function (self $model) use ($tenants) {
            $model->syncTenants($tenants);
        });
    }
446471
public function onDedimaniaRecordsLoaded($records)
    {
        if (count($records) > 0) {
            $this->widget->setDedimaniaRecord($records[0]);
        } else {
            $this->widget->setDedimaniaRecord(null);
        }
        $this->widget->update($this->allPlayers);
    }
1221386
public function load($entities, $depth = 1)
    {
        if (!\is_array($entities) && !$entities instanceof \Traversable) {
            throw new \InvalidArgumentException(self::E_MSG);
        }

        $entitiesByValueClassByIds = $this->sortEntitiesByValueClass($entities);
        foreach ($entitiesByValueClassByIds as $valueClass => $entitiesById) {
            $this->loadEntityValues($valueClass, $entitiesById);
        }

        $this->loadRelatedEntities($entities, $depth);
    }
111622
public function detach($ids = null, $touch = true)
    {
        $query = $this->newPivotQuery();

        // If associated IDs were passed to the method we will only delete those
        // associations, otherwise all of the association ties will be broken.
        // We'll return the numbers of affected rows when we do the deletes.
        if (! is_null($ids)) {
            $ids = $this->parseIds($ids);

            if (empty($ids)) {
                return 0;
            }

            $query->whereIn($this->relatedKey, $ids);
        }

        // Once we have all of the conditions set on the statement, we are ready
        // to run the delete on the pivot table. Then, if the touch parameter
        // is true, we will go ahead and touch all related models to sync.
        $results = $query->delete();

        if ($touch) {
            $this->touchIfTouching();
        }

        return $results;
    }
999279
public function setTagsAttribute($tags): void
    {
        static::saved(function (self $model) use ($tags) {
            $model->syncTags($tags);
        });
    }
772707
public function syncAll(array $options = [])
    {
        $this->logger->info('Synchronizing categories');
        $this->recursiveSync(0);

        $cache = [];

        $this->logger->info('Synchronizing parent/child relationships');

        // when all categories has been saved we iterate through them to update their parent/child relationship
        // @todo this should probably be moved to the updater
        foreach ($this->repository->iterate(['update' => true]) as $category) {
            foreach ($category->getParentIdList() as $parentNumber) {
                if (isset($cache[$parentNumber])) {
                    $parent = $this->repository->getReference($cache[$parentNumber]);
                } else {
                    // @todo if an existing relationship that has been deleted in Dandomain then it isn't updated here
                    $parent = $this->repository->findOneByNumber($parentNumber);
                    $cache[$parentNumber] = $parent->getId();
                }

                if ($parent) {
                    $category->addParentCategory($parent);
                }
            }
        }
    }
99064
public function sync(Model $model, $relation, $ids, $detaching = true)
    {
        return $model->{$relation}()->sync($ids, $detaching);
    }
1134229
public function generateNextRoundsFights()
    {
        $fightersCount = $this->championship->competitors->count() + $this->championship->teams->count();
        $maxRounds = $this->getNumRounds($fightersCount);
        for ($numRound = 1; $numRound < $maxRounds; $numRound++) {
            $groupsByRound = $this->championship->fightersGroups()->where('round', $numRound)->with('parent', 'children')->get();
            $this->updateParentFight($groupsByRound); // should be groupsByRound
        }
    }
770173
public function attach($conn, $inf = null)
    {
        parent::attach($conn, $inf);
        if ($this->maxConcurrency && !$this->overload) {
            if ($this->count() >= $this->maxConcurrency) {
                $this->overload = true;
                $this->disable();
                return;
            }
        }
    }
948556
public function foreverMany(array $items)
    {
        if (! method_exists($this->store, 'foreverMany')) {
            array_map([$this, 'forever'], array_keys($items), array_values($items));
        } else {
            $this->store->foreverMany($items);

            foreach ($items as $key => $value) {
                $this->fireCacheEvent('write', [$key, $value, 0]);
            }
        }
    }
688466
public function synchronize($className, $force)
    {
        $this->logger->notice(
            'Start of ' . ($force ? 'forced ' : '') . 'synchronization for {className}.',
            array('className' => $className)
        );

        $this->className = $className;
        $this->mapper->setForce($force);

        $this->sourceQueue = $this->source->getObjectsOrderedById();
        $this->sourceQueue->rewind();

        $this->destinationQueue = $this->destination->getObjectsOrderedById($className);
        $this->destinationQueue->rewind();

        while ($this->sourceQueue->valid() && $this->destinationQueue->valid()) {
            $this->compareQueuesAndReactAccordingly();
        }

        $this->insertRemainingSourceObjects();
        $this->deleteRemainingDestinationObjects();

        $this->destination->commit();
        $this->logger->notice('End of synchronization for {className}.', array('className' => $className));
    }