/** * Return all children for the specified node. * * @param Tree\Node $node * @return Illuminate\Database\Eloquent\Collection */ public function children($node) { $query = $this->node->newQuery(); $query->where($this->node->getQualifiedParentColumnName(), '=', $node->getKey()); // We must also add the scoped column values to the query to compute valid // left and right indexes. foreach ($this->scopedAttributes($node) as $fld => $value) { $query->where($this->qualify($fld), '=', $value); } $query->orderBy($this->node->getQualifiedLeftColumnName()); $query->orderBy($this->node->getQualifiedRightColumnName()); $query->orderBy($this->node->getQualifiedKeyName()); return $query->get(); }
/** * Checks that there are no duplicates for the `lft` and `rgt` columns. * * @return boolean */ protected function validateDuplicates() { return !$this->duplicatesExistForColumn($this->node->getQualifiedLeftColumnName()) && !$this->duplicatesExistForColumn($this->node->getQualifiedRightColumnName()); }