Xpressengine\Category\Models\CategoryItem::getChildren PHP Method

getChildren() public method

Get a children collection of model
public getChildren ( ) : Illuminate\Database\Eloquent\Collection
return Illuminate\Database\Eloquent\Collection
    public function getChildren()
    {
        if (!$this->children) {
            $this->children = $this->where($this->getParentIdName(), $this->getKey())->get()->sort(function (Node $a, Node $b) {
                $aOrdering = $a->{$a->getOrderKeyName()};
                $bOrdering = $b->{$b->getOrderKeyName()};
                if ($aOrdering == $bOrdering) {
                    return 0;
                }
                return $aOrdering < $bOrdering ? -1 : 1;
            });
        }
        return $this->children;
    }