Last active
November 22, 2023 13:33
-
-
Save sawirricardo/ff547ba3afebe0139aeb49404fe88c51 to your computer and use it in GitHub Desktop.
It captures responses, handles DB transactions, and allows custom error messages.
This file contains 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 App\Http\Middleware; | |
use Closure; | |
use Illuminate\Http\Request; | |
use Illuminate\Support\Facades\DB; | |
class TransactionEncapsulation | |
{ | |
public function handle(Request $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