PHP code example of azmolla / transaction-middleware

1. Go to this page and download the library: Download azmolla/transaction-middleware library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

azmolla / transaction-middleware example snippets




return [
    'auto_apply_global' => false,
    'auto_apply_web'     => false,
    'auto_apply_api'     => false,
];

  'auto_apply_global' => true,
  'auto_apply_web'     => false,
  'auto_apply_api'     => false,
  

  'auto_apply_global' => false,
  'auto_apply_web'     => true,
  'auto_apply_api'     => false,
  

  'auto_apply_global' => false,
  'auto_apply_web'     => false,
  'auto_apply_api'     => true,
  

Route::delete('/posts/{post}', [PostController::class, 'destroy'])
    ->middleware('transaction');

use Azmolla\TransactionMiddleware\Traits\HasTransactionalCalls;

class MyModel
{
    use HasTransactionalCalls;
}

$model->transaction()->delete();

$model->transaction(function(Model $model) {
    $model->update();
    $model->child->update();
});
bash
php artisan vendor:publish --tag=transaction-middleware-config