/**
* @param mixed $data
* @return int|void
*/
public function deleteOne($data)
{
$table = Table::getInstance();
$tree = $table->buildTree($data['id']);
if (!isset($tree[0]['children'])) {
parent::deleteOne($data);
} else {
$allSubCategories = $this->treeToArray($tree);
foreach ($allSubCategories as $categoryId) {
parent::deleteOne(['id' => $categoryId]);
}
}
}