/** * Override for the destroy function */ public function destroy($index = 0) { $this->children = null; $this->getChildren(); for ($i = 0; $i < count($this->children); $i++) { $this->children[$i]->destroy(); } $this->children = null; $this->getChildren(); if (count($this->children) == 0) { parent::destroy(); } }