Answers for "laravel 8 eloquent transaction"

PHP
1

DB::transaction

DB::beginTransaction();

try {
    DB::insert(...);
    DB::insert(...);
    DB::insert(...);

    DB::commit();
    // all good
} catch (\Exception $e) {
    DB::rollback();
    // something went wrong
}
Posted by: Guest on October-20-2020
4

TRANSACTON LARAVEL QUERY BUILDER

DB::beginTransaction();

try {
    DB::insert(...);    
    DB::commit();
} catch (\Throwable $e) {
    DB::rollback();
    throw $e;
}
Posted by: Guest on September-22-2020
0

laravel transactions eloquent

DB::transaction(function() {
      //
});
Posted by: Guest on August-08-2021

Code answers related to "laravel 8 eloquent transaction"

Browse Popular Code Answers by Language