Created
September 4, 2018 03:24
-
-
Save sanathks/2a3173f798095bb600843e56400c5b91 to your computer and use it in GitHub Desktop.
Laravel Database transaction middleware
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Core\Http\Middleware; | |
use Closure; | |
use Illuminate\Contracts\Auth\Guard; | |
use Illuminate\Contracts\Validation\UnauthorizedException; | |
use Illuminate\Support\Facades\DB; | |
use Symfony\Component\HttpFoundation\Response; | |
class DatabaseTransactions | |
{ | |
/** | |
* The Guard implementation. | |
* | |
* @var Guard | |
*/ | |
protected $auth; | |
public function handle($request, Closure $next) | |
{ | |
return DB::transaction(function () use ($request, $next) { | |
return $next($request); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment