Skip to content

Instantly share code, notes, and snippets.

@uno-de-piera
Last active September 19, 2017 12:36
Show Gist options
  • Save uno-de-piera/cb945a3060a667ab19a3866ad0b2b98d to your computer and use it in GitHub Desktop.
Save uno-de-piera/cb945a3060a667ab19a3866ad0b2b98d to your computer and use it in GitHub Desktop.
<?php
public function store()
{
$error = null;
DB::beginTransaction();
try {
Module::buildComponent("type1");
Module::buildComponent("type2");
Module::buildComponent("type3");
DB::commit();
$success = true;
} catch (\Exception $e) {
$success = false;
$error = $e->getMessage();
DB::rollback();
}
if ($success) {
//success
}
//error
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment