Example #1
0
 private function createNewCollection($relationship)
 {
     if ($relationship instanceof FieldRelationship) {
         if ($relationship->isMultiple) {
             if ($relationship->isPolymorphic) {
                 $this->relatedViaFieldOnEntity[$relationship->relationshipName] = PolymorphicCollection::forge(null);
             } else {
                 $this->relatedViaFieldOnEntity[$relationship->relationshipName] = Collection::forge($relationship->modelType);
             }
         } else {
             throw new InvalidTypeException('Single Field Relationships do not require a collection');
         }
     } else {
         if ($relationship instanceof ReferencedRelationship) {
             $this->relatedViaFieldOnExternalEntity[$relationship->relationshipName] = Collection::forge($relationship->modelType);
         }
     }
 }