src/Leevel/Database/Ddd/Relation/ManyMany.php
public function sourceQuery()
    {
        $tmps = $this->select->findAll();

        if (!$tmps) {
            return new Collection();
        }

        $result = [];

        $middelClass = get_class($this->middleEntity);
        $targetClass = get_class($this->targetEntity);

        foreach ($tmps as $value) {
            $value = (array) $value;

            $middleEnity = new $middelClass([
                $this->middleSourceKey => $value['middle_'.$this->middleSourceKey],
                $this->middleTargetKey => $value['middle_'.$this->middleTargetKey],
            ]);

            unset(
                $value['middle_'.$this->middleSourceKey],
                $value['middle_'.$this->middleTargetKey]
            );

            $targetEntity = new $targetClass($value);

            $targetEntity->withMiddle($middleEnity);

            $result[] = $targetEntity;
        }

        return new Collection($result, [$targetClass]);
    }
public function sourceQuery()
    {
        $tmps = $this->select->findAll();

        if (!$tmps) {
            return new Collection();
        }

        $result = [];

        $middelClass = get_class($this->middleEntity);
        $targetClass = get_class($this->targetEntity);

        foreach ($tmps as $value) {
            $value = (array) $value;

            $middleEnity = new $middelClass([
                $this->middleSourceKey => $value['middle_'.$this->middleSourceKey],
                $this->middleTargetKey => $value['middle_'.$this->middleTargetKey],
            ]);

            unset(
                $value['middle_'.$this->middleSourceKey],
                $value['middle_'.$this->middleTargetKey]
            );

            $targetEntity = new $targetClass($value);

            $targetEntity->withMiddle($middleEnity);

            $result[] = $targetEntity;
        }

        return new Collection($result, [$targetClass]);
    }
查询关联对象.

@return mixed