Skip to content

Instantly share code, notes, and snippets.

@andrewmmc
Last active January 8, 2018 07:46
Show Gist options
  • Save andrewmmc/9cc34c2f7e44b66ff3386ca6c5531a3b to your computer and use it in GitHub Desktop.
Save andrewmmc/9cc34c2f7e44b66ff3386ca6c5531a3b to your computer and use it in GitHub Desktop.
[Laravel] Databse Transactions

Laravel 5 - Manually Using Transactions

If you would like to begin a transaction manually and have complete control over rollbacks and commits, you may use the beginTransaction method on the DB facade:

DB::beginTransaction();

You can rollback the transaction via the rollBack method:

DB::rollBack();

Lastly, you can commit a transaction via the commit method:

DB::commit();

Reference: https://laravel.com/docs/5.5/database

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment