Example #1
0
 /**
  * Adds data to the Collection
  * @param mixed $data
  * @param null|mixed $key
  */
 protected function addTo($data, $key = null)
 {
     $model = null;
     if ($data instanceof \Jazz\IModel) {
         $model = $data;
         $data = $model->all();
     } else {
         if (is_array($data)) {
             $data = $this->structure()->swapColumnsForKeys($data);
         }
     }
     $pos = parent::addTo($data);
     if ($model !== null) {
         $this->_objects[$pos] = $model;
     }
     return $pos;
 }