@@ 685-696 (lines=12) @@ | ||
682 | * @throws MappingException |
|
683 | * @return \Analogue\ORM\Relationships\MorphOne |
|
684 | */ |
|
685 | public function morphOne($entity, $related, $name, $type = null, $id = null, $localKey = null) |
|
686 | { |
|
687 | list($type, $id) = $this->getMorphs($name, $type, $id); |
|
688 | ||
689 | $localKey = $localKey ?: $this->getKeyName(); |
|
690 | ||
691 | $relatedMapper = $this->manager->mapper($related); |
|
692 | ||
693 | $table = $relatedMapper->getEntityMap()->getTable(); |
|
694 | ||
695 | return new MorphOne($relatedMapper, $entity, $table . '.' . $type, $table . '.' . $id, $localKey); |
|
696 | } |
|
697 | ||
698 | /** |
|
699 | * Define an inverse one-to-one or many relationship. |
|
@@ 847-861 (lines=15) @@ | ||
844 | * @param string|null $localKey |
|
845 | * @return \Analogue\ORM\Relationships\MorphMany |
|
846 | */ |
|
847 | public function morphMany($entity, $related, $name, $type = null, $id = null, $localKey = null) |
|
848 | { |
|
849 | // Here we will gather up the morph type and ID for the relationship so that we |
|
850 | // can properly query the intermediate table of a relation. Finally, we will |
|
851 | // get the table and create the relationship instances for the developers. |
|
852 | list($type, $id) = $this->getMorphs($name, $type, $id); |
|
853 | ||
854 | $relatedMapper = $this->manager->mapper($related); |
|
855 | ||
856 | $table = $relatedMapper->getEntityMap()->getTable(); |
|
857 | ||
858 | $localKey = $localKey ?: $this->getKeyName(); |
|
859 | ||
860 | return new MorphMany($relatedMapper, $entity, $table . '.' . $type, $table . '.' . $id, $localKey); |
|
861 | } |
|
862 | ||
863 | /** |
|
864 | * Define a many-to-many relationship. |