Using closures into DB::transaction() to roll back

Using closures into DB::transaction() to roll back

Reference

Laravel tip - you can provide a closure into DB::transaction() and if any errors happen, the entire transaction will be rolled back. This is great for registration if you are creating other models after the user. If anything else fails, the user won't be created.

Transaction

 

Categories: Category 1