/**
  * Set the constraints for an eager load of the relation.
  *
  * @param  array $models
  *
  * @return void
  */
 public function addEagerConstraints(array $models)
 {
     $this->query->whereNested(function (Builder $inner) use($models) {
         // We will use this query in order to apply constraints to the
         // base query builder
         $outer = $this->parent->newQuery();
         foreach ($models as $model) {
             $outer->setQuery($inner)->orWhereDescendantOf($model);
         }
     });
 }
Example #2
0
 /**
  * @param string|null $table
  *
  * @return $this
  */
 public function applyNestedSetScope($table = null)
 {
     return $this->model->applyNestedSetScope($this, $table);
 }
Example #3
0
 /**
  * @param NodeTrait $node
  *
  * @return $this
  */
 protected function assertNodeExists(self $node)
 {
     if (!$node->getLft() || !$node->getRgt()) {
         throw new LogicException('Node must exists.');
     }
     return $this;
 }