LMongo\Eloquent\Builder::setModel PHP Method

setModel() public method

Set a model instance for the model being queried.
public setModel ( Model $model ) : Builder
$model Model
return Builder
    public function setModel(Model $model)
    {
        $this->model = $model;
        $this->query->collection($model->getCollection());
        return $this;
    }

Usage Example

 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));
 }
All Usage Examples Of LMongo\Eloquent\Builder::setModel