Get the many 2 many relationship with the Null Rows.

@return Collection
14959
public function competitorsWithBye(): Collection
    {
        $competitors = new Collection();
        $fgcs = FighterGroupCompetitor::where('fighters_group_id', $this->id)
            ->with('competitor')
            ->get();

        foreach ($fgcs as $fgc) {
            $competitors->push($fgc->competitor ?? new Competitor());
        }

        return $competitors;
    }
609699
public function createMany(): Collection
	{
		$collection = new Collection();

		foreach ($this->getInput() as $item) {
			$repository = clone $this;
			$repository->setInput($item);
			$collection->add($repository->create());
		}

		return $collection;
	}
1171532
public function getNonLazyRelationships()
    {
        $rels = [];
        foreach ($this->relationships as $relationship) {
            if (!$relationship->isLazy()) {
                $rels[] = $relationship;
            }
        }

        return $rels;
    }
369342
private function formatBelongsToMany()
    {
        // Return if there are no relationships of that type
        if (!isset($this->relationships['belongsToMany']) || empty($this->relationships['belongsToMany'])) {
            return $this;
        }

        // Iterate relationships
        foreach ($this->relationships['belongsToMany'] as $join) {
            $this->records = array_map(function ($record) use ($join) {
                foreach ($record as $key => $value) {
                    if ($key === 'concat_' . $join['alias']) {
                        $record[$join['alias']] = ($value)? explode(',', $value) : [];
                        unset($record[$key]);
                    }
                }
                return $record;
            }, $this->records);
        }

        // Return model instance
        return $this;
    }
1245887
public function getResult()
    {
        $result = $this->execute();
        $list = new ArrayCollection;

        //Loop through results
        foreach ($result as $row)
        {
            $entry = array();

            //Loop through entities attributes (or relations)
            foreach ($row as $key => $value)
            {
                $entry[$key] = $this->convertValue($value);
            }

            //Add to list
            $list->add($entry);
        }

        return $list;
    }
1346636
private function getRelationships()
    {
        $relationships = [];

        // Loop through input, and check whether any key is a valid relationship
        foreach ($this->dataset as $model => $value)
        {
            // Skip anything which isn't a valid relationship
            if ( ! $this->isRelationship($model, $this->conditions)) continue;

            // Capture relationship and it's type
            $relationships[$model] = $this->getRelationshipType(Str::camel($model));
        }

        return $relationships;
    }
284206
public function getList()
    {
        if ($this->kind === 'collection') {
            $model_class = $this->model_class;
            return $model_class::dump($this->where, $model_class::PRIMARY_KEY);
        }
        return [$this->where];
    }
1162450
public function getCollection()
    {
        $collection = trim(str_replace('\\', '_', $this->collection), '_');
        return $this->$collection()
            ->setDatabase($this->database)
            ->setTable($this->table)
            ->setModel($this->model)
            ->set($this->getRows());
    }
1009783
function getRelations() {
		if (!isset($this->relations)) {
			$this->relations = new Table\Relations($this);
		}
		return $this->relations;
	}
1300571
protected function getListCollection()
    {
        $conditions = $this->query_filter;
        $conditions['limit'] = $this->data_limit;

        return (array) $this->collection->getList($conditions);
    }
1141995
public function getRelations($many = -1)
    {
        $results = [];
        if (!isset($this->data['relations'])
            || empty($this->data['relations'])
        ) {
            return $results;
        }

        $table = $this->getName();
        $primary = $this->getPrimaryFieldName();

        foreach ($this->data['relations'] as $relation) {
            if (is_numeric($many) && $many != -1 && $many != $relation['many']) {
                continue;
            }

            //case for getting a specific relation
            if (!is_numeric($many) && $relation['name'] !== $many) {
                continue;
            }

            $name = $table . '_' . $relation['name'];

            $results[$name] = [];

            try {
                $results[$name] = Schema::i($relation['name'])->getAll(false);
            } catch (Exception $e) {
                //this is not a registered schema
                //lets make a best guess
                $results[$name]['name'] = $relation['name'];
                $results[$name]['singular'] = ucfirst($relation['name']);
                $results[$name]['plural'] = $results[$name]['singular'] . 's';
                $results[$name]['primary'] =  $relation['name'] . '_id';
            }

            $results[$name]['table'] = $name;
            $results[$name]['primary1'] = $primary;
            $results[$name]['primary2'] = $results[$name]['primary'];
            $results[$name]['many'] = $relation['many'];
            $results[$name]['source'] = $this->getAll(false);

            //case for relating to itself ie. post_post
            if ($table === $relation['name']) {
                $results[$name]['primary1'] .= '_1';
                $results[$name]['primary2'] .= '_2';
            }

            //case for getting a specific relation
            if (!is_numeric($many) && $relation['name'] === $many) {
                return $results[$name];
            }
        }

        return $results;
    }
531970
public function getRelationTable()
    {
        if (is_null($this->relationTable)) {
            $parentTable = $this->getParentTableName();
            $table = $this->getEntityDescriptor()->getTableName();
            $names = [$parentTable, $table];
            asort($names);
            $first = array_shift($names);
            $tableName = $this->normalizeFieldName($first);
            array_unshift($names, $tableName);
            $this->relationTable = implode('_', $names);
        }
        return $this->relationTable;
    }
560841
public function getResults()
    {
        return ! is_null($this->getParentKey())
                ? $this->query->get()
                : $this->related->newCollection();
    }
807050
public function getRelations()
    {
        if (!isset($this->relationships)) {
            $this->relationships = array();
            // load them manually
            $mm = $this->getModelsManager();
            $relationships = $mm->getRelations(get_class($this));
            // Temporary fix because $mm->getRelations() doesn't support hasManyToMany relations right now.
            // get them separately and merge them
            $mtmRelationships = $mm->getHasManyToMany($this);

            $relationships = array_merge($relationships, $mtmRelationships);

            foreach ($relationships as $relation) {
                // todo load custom relationship
                $this->relationships[] = new Relation($relation, $mm);
            }
        }
        return $this->relationships;
    }
975541
public function related()
    {
        $collections = self::get("/collections/{$this->id}/related");
        $collectionsArray = self::getArray($collections->getBody(), get_called_class());
        return new ArrayObject($collectionsArray, $collections->getHeaders());
    }
114731
public function reloadModelsWithRelationCount(): self
    {
        /** @var \Illuminate\Database\Eloquent\Builder $query */
        $query = $this->models()
            ->first()
            ->newQuery()
            ->withCount($this->relations);

        $ids = $this->getModelIds();

        $reloadedModels = $query
            ->whereKey($ids)
            ->get()
            ->filter(function (Model $model) use ($ids) {
                return in_array(
                    $model->getKey(),
                    $ids,
                    true
                );
            });

        return $this->setModels($reloadedModels);
    }
473660
public function getList()
    {
        $result = $this->execute();
        $list = new ArrayCollection;

        //Convert all of them to entities
        foreach ($result as $row)
        {
            $list->add($this->convertValue($row[0]));
        }

        return $list;
    }