Ejemplo n.º 1
0
 /**
  * Execute the query as a "select" statement.
  *
  * @param  array  $columns
  * @return \Illuminate\Database\Eloquent\Collection
  */
 public function get($columns = array('*'))
 {
     if (empty($this->getParent()->getKey())) {
         return parent::get($columns);
     }
     $models = $this->related->whereIn($this->getForeignKey(), $this->getParent()->getKey())->getModels();
     $this->hydratePivotRelation($models);
     if (count($models) > 0) {
         $models = $this->query->eagerLoadRelations($models);
     }
     return $this->related->newCollection($models);
 }