示例#1
0
 /**
  * Return all children for the specified node.
  *
  * @param   \AwatBayazidi\Foundation\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();
 }