public function getAncestors()
    {
        $ancestors = new Collection();

        $ancestor = $this;

        while (($ancestor = $ancestor->parent) && !$ancestors->contains($ancestor)) {
            $ancestors->push($ancestor);
            break;
        }

        return $ancestors;
    }
public function getAncestors()
    {
        $ancestors = new Collection();

        $ancestor = $this;

        while (($ancestor = $ancestor->parent) && !$ancestors->contains($ancestor)) {
            $ancestors->push($ancestor);
            break;
        }

        return $ancestors;
    }
public function getAncestors ( ) { $ ancestors = new Collection ( ) ; $ ancestor = $ this ; while ( ( $ ancestor = $ ancestor -> parent ) && ! $ ancestors -> contains ( $ ancestor ) ) { $ ancestors -> push ( $ ancestor ) ; break ; } return $ ancestors ; }
Recursively build collection of ancestor category IDs.

@return \Illuminate\Support\Collection
Recursively build collection of ancestor category IDs .