/** * Convert the model instance to an array. * * @return array */ public function toArray() { $tree = $this->getTree(); return array_merge(parent::toArray(), ['items' => $tree, 'entity' => 'menu', 'itemCount' => $tree->size()]); }