public function clearTemplateFields($templateName)
{
DB::beginTransaction();
try {
$page = $this->fakeAPageRender($templateName);
$keys = $this->getActiveKeys();
$allIds = $this->getIdsToDelete($templateName, $keys, $page->version->id);
$this->deleteFields($allIds['fields']);
$this->deleteCollectionInstances($allIds['collection_instances']);
$this->deleteCollections($allIds['collections']);
} catch (\Exception $e) {
// if anything guest wrong, rollback the database changes.
DB::rollback();
throw $e;
}
DB::commit();
return true;
}