You can do this:
DB::transaction(function() {
//
});
Everything inside the Closure executes within a transaction. If an exception occurs it will rollback automatically.
More Related Contents:
- What are these exactly?: Composer, Git and Pyrus [closed]
- Laravel 5 – How to access image uploaded in storage within View?
- How to do this in Laravel, subquery where in
- How to create Helper Methods on Laravel not a Facade
- Download files in laravel using Response::download
- Laravel update model with unique validation rule for attribute
- Sorting Laravel Collection via Array of ID’s
- Get the Query Executed in Laravel 3/4
- Laravel – htmlspecialchars() expects parameter 1 to be string, object given
- What does “Mass Assignment” mean in Laravel?
- Laravel Eloquent display query log
- Laravel Checking If a Record Exists
- Accessing Laravel .env variables in blade
- laravel TokenMismatchException in ajax request
- change the date format in laravel view page [duplicate]
- How to pass a PHP variable to Vue component instance in Laravel blade?
- Laravel 5.2 Auth not Working
- Laravel 5 – Clear Cache in Shared Hosting Server
- Passing data from controller to view in Laravel
- How to set the default value of an attribute on a Laravel model [duplicate]
- php artisan migrate throwing [PDO Exception] Could not find driver – Using Laravel
- Change name of Laravel’s created_at and updated_at
- How do I get database column names in Laravel?
- Eloquent many-to-many-to-many – how to load distant relation easily
- Laravel Eager Loading – Load only specific columns
- Laravel catch Eloquent “Unique” field error
- ErrorException : implode(): Passing glue string after array is deprecated. Swap the parameters
- How to get last insert id in Eloquent ORM laravel
- How to remove /public/ from a Laravel URL
- Unit Test Laravel’s FormRequest