setModel() 공개 메소드

Set a model instance for the model being queried.
public setModel ( Model $model ) : Builder
$model Model
리턴 Builder
예제 #1
0
 public function testWithDeletedProperlyRemovesDeletedClause()
 {
     $builder = new LMongo\Eloquent\Builder(new LMongo\Query\Builder(m::mock('LMongo\\Connection')));
     $model = m::mock('LMongo\\Eloquent\\Model');
     $model->shouldReceive('getCollection')->once()->andReturn('');
     $model->shouldReceive('getQualifiedDeletedAtColumn')->once()->andReturn('deleted_at');
     $builder->setModel($model);
     $builder->getQuery()->where('updated_at', null);
     $builder->getQuery()->where('deleted_at', null);
     $builder->getQuery()->where('foo_bar', null);
     $builder->withTrashed();
     $this->assertEquals(2, count($builder->getQuery()->wheres));
 }
예제 #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;
 }
예제 #3
0
파일: Model.php 프로젝트: shershams/lmongo
 /**
  * Get a new query builder for the model's table.
  *
  * @return LMongo\Eloquent\Builder
  */
 public function newQuery()
 {
     $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);
     return $builder;
 }