/** * Create a new relation instance. * * @param LMongo\Eloquent\Builder * @param LMongo\Eloquent\Model * @return void */ public function __construct(Builder $query, Model $parent) { $this->query = $query; $this->parent = $parent; $this->related = $query->getModel(); $this->addConstraints(); }
/** * Remove the original where clause set by the relationship. * * The remaining constraints on the query will be reset and returned. * * @return array */ public function getAndResetWheres() { // When a model is "soft deleting", the "deleted at" where clause will be the // first where clause on the relationship query, so we will actually clear // the second where clause as that is the lazy loading relations clause. if ($this->query->getModel()->isSoftDeleting()) { $this->removeSecondWhereClause(); } else { $this->removeFirstWhereClause(); } return $this->getBaseQuery()->getAndResetWheres(); }