public function fetchCollection()
 {
     $entities = $this->fetch();
     return SpectrumCollection::forge($this->modelType, null, $entities);
 }
 public function put($relationship, $model)
 {
     if ($model != null && is_a($model, 'SpectrumModel')) {
         if (is_a($relationship, 'SpectrumParentRelationship')) {
             if (!array_key_exists($relationship->relationshipName, $this->parents)) {
                 $this->parents[$relationship->relationshipName] = $model;
             }
         } else {
             if (is_a($relationship, 'SpectrumChildRelationship')) {
                 if (!array_key_exists($relationship->relationshipName, $this->children)) {
                     $this->children[$relationship->relationshipName] = SpectrumCollection::forge($relationship->modelType);
                 }
                 $this->children[$relationship->relationshipName]->put($model);
             }
         }
     }
 }
 public static function forge($modelType, $models = array(), $entities = array(), $ids = array(), $modelQuery = null)
 {
     $collection = new SpectrumCollection();
     $collection->modelType = $modelType;
     if (is_array($ids) && !empty($ids)) {
         $entities = SpectrumCollection::fetchEntities($modelType, $ids);
     }
     if (is_array($entities) && !empty($entities)) {
         $models = SpectrumCollection::getModels($modelType, $entities);
     }
     if (is_array($models) && !empty($models)) {
         $collection->setModels($models);
     }
     return $collection;
 }