The package can be used to handle DB transaction through a middleware.
iamarunp/laraveldbtransactions is a Laravel package for the package can be used to handle db transaction through a middleware..
It currently has 0 GitHub stars and 14 downloads on Packagist.
Install it with composer require iamarunp/laraveldbtransactions.
Discover more Laravel packages by iamarunp
or browse all Laravel packages to compare alternatives.
Last updated
This package introduces the simplest way, you can achieve the database transaction without making your code complex, without making a lot of changes.the middleware can be used for individual routes or for a route group ,if an exception occurs then it will rollback from the Terminable Middleware. While if queries getting executed successfully then the transaction gets committed. In Laravel, DB facades provide the transaction for both query builder as well as eloquent ORM.
composer require iamarunp/laraveldbtransactions
The terminate method will be automatically called after the response is ready to be sent to the browser.
The middleware is registered using TransactionServiceProvider, to use the provider, you need register the service provider.
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
'providers' => [ /* * Laravel Framework Service Providers... */ Illuminate\Auth\AuthServiceProvider::class, Illuminate\Broadcasting\BroadcastServiceProvider::class, Illuminate\Bus\BusServiceProvider::class, Illuminate\Cache\CacheServiceProvider::class, Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, Illuminate\Cookie\CookieServiceProvider::class, Illuminate\Database\DatabaseServiceProvider::class, Illuminate\Encryption\EncryptionServiceProvider::class, Illuminate\Filesystem\FilesystemServiceProvider::class, Illuminate\Foundation\Providers\FoundationServiceProvider::class, Illuminate\Hashing\HashServiceProvider::class, Illuminate\Mail\MailServiceProvider::class, Illuminate\Notifications\NotificationServiceProvider::class, Illuminate\Pagination\PaginationServiceProvider::class, Illuminate\Pipeline\PipelineServiceProvider::class, Illuminate\Queue\QueueServiceProvider::class, Illuminate\Redis\RedisServiceProvider::class, Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, Illuminate\Session\SessionServiceProvider::class, Illuminate\Translation\TranslationServiceProvider::class, Illuminate\Validation\ValidationServiceProvider::class, Illuminate\View\ViewServiceProvider::class, /* * Package Service Providers... */ Laravel\Tinker\TinkerServiceProvider::class, /* * Application Service Providers... */ App\Providers\AppServiceProvider::class, App\Providers\AuthServiceProvider::class, // App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, iamarunp\Laraveldbtransactions\TransactionServiceProvider::,
class,], |
Route::group(['middleware' => 'TransactionHandler'], function () {
Route::get('/home', [
'as' => 'home',
'uses' => 'Dashboard\DashboardController@dashboard'
]);
Route::resource('users','UserController');
// more route definitions
});
Route::get('/', function () {
//
})->middleware(['TransactionHandler', 'second']);