LMongo\Eloquent\Model::newCollection PHP Method

newCollection() public method

Create a new Collection instance.
public newCollection ( array $models = [] ) : Collection
$models array
return Collection
    public function newCollection(array $models = array())
    {
        return new Collection($models);
    }

Usage Example

示例#1
0
 /**
  * Execute the query as a "select" statement.
  *
  * @param  array  $columns
  * @return \LMongo\Eloquent\Collection
  */
 public function get($columns = array())
 {
     $models = $this->getModels($columns);
     // If we actually found models we will also eager load any relationships that
     // have been specified as needing to be eager loaded, which will solve the
     // n+1 query issue for the developers to avoid running a lot of queries.
     if (count($models) > 0) {
         $models = $this->eagerLoadRelations($models);
     }
     return $this->model->newCollection($models);
 }
Model