commit | author | age
|
9f6455
|
1 |
<?php |
DC |
2 |
|
|
3 |
namespace App\Traits; |
|
4 |
|
|
5 |
use Illuminate\Support\Facades\DB; |
|
6 |
|
|
7 |
trait AllowTransaction |
|
8 |
{ |
|
9 |
/** |
|
10 |
* @throws \Exception |
|
11 |
*/ |
|
12 |
public function transactionStart() |
|
13 |
{ |
|
14 |
try { |
|
15 |
DB::beginTransaction(); |
|
16 |
} catch (\Exception $e) { |
|
17 |
throw ($e); |
|
18 |
} |
|
19 |
} |
|
20 |
|
|
21 |
/** |
|
22 |
* @throws \Exception |
|
23 |
*/ |
|
24 |
public function transactionCommit() |
|
25 |
{ |
|
26 |
try { |
|
27 |
DB::commit(); |
|
28 |
} catch (\Exception $e) { |
|
29 |
throw ($e); |
|
30 |
} |
|
31 |
} |
|
32 |
|
|
33 |
/** |
|
34 |
* @throws \Exception |
|
35 |
*/ |
|
36 |
public function transactionRollBack() |
|
37 |
{ |
|
38 |
try { |
|
39 |
DB::rollBack(); |
|
40 |
} catch (\Exception $e) { |
|
41 |
throw ($e); |
|
42 |
} |
|
43 |
} |
|
44 |
} |