DB::beginTransaction();
try {
$project = Project::find($id);
$project->users()->detach();
$project->delete();
DB::commit();
} catch (Exception $ex) {
DB::rollback();
return response()->json(['error' => $ex->getMessage()], 500);
}
DB::beginTransaction();
try {
DB::insert(...);
DB::commit();
} catch (Exception $e) {
DB::rollback();
throw $e;
} catch (Throwable $e) {
DB::rollback();
throw $e;
}
DB::beginTransaction();
try{
DB::Commit();
} catch (Exception $e) {
DB::rollback();
}
DB::beginTransaction();
try { /** Statement */ DB::commit(); }
catch (Exception $e) { /** Statement if failed */ DB::rollback(); }