/** * Get the ancestors. * * @uses \get_ancestors() * * @return \Illuminate\Support\Collection|\Luminous\Bridge\Term\Entity[] */ protected function getAncestorsAttribute() { $ancestors = array_map(function ($id) { return WP::term($id, $this->type); }, get_ancestors($this->id, $this->original->taxonomy, 'taxonomy')); return new Collection($ancestors); }