예제 #1
0
파일: Builder.php 프로젝트: navruzm/lmongo
 /**
  * Find a model by its primary key.
  *
  * @param  mixed  $id
  * @param  array  $columns
  * @return \LMongo\Eloquent\Model|null
  */
 public function find($id, $columns = array())
 {
     if (!$id instanceof MongoID) {
         $id = new MongoID($id);
     }
     $this->query->where($this->model->getKeyName(), $id);
     return $this->first($columns);
 }
예제 #2
0
파일: Model.php 프로젝트: navruzm/lmongo
 /**
  * Get a new query builder for the model's table.
  *
  * @param  bool  $excludeDeleted
  * @return \LMongo\Eloquent\Builder
  */
 public function newQuery($excludeDeleted = true)
 {
     $builder = new Builder($this->newBaseQueryBuilder());
     // Once we have the query builders, we will set the model instances so the
     // builder can easily access any information it may need from the model
     // while it is constructing and executing various queries against it.
     $builder->setModel($this)->with($this->with);
     if ($excludeDeleted and $this->softDelete) {
         $builder->where($this->getQualifiedDeletedAtColumn(), null);
     }
     return $builder;
 }