DB::beginTransaction(); try { DB::insert(...); DB::insert(...); DB::insert(...); DB::commit(); // all good } catch (\Exception $e) { DB::rollback(); // something went wrong }
DB::beginTransaction(); try { DB::insert(...); DB::commit(); } catch (\Throwable $e) { DB::rollback(); throw $e; }
Start the transaction on the same connection your query will run on.