Reputation: 21
I did some diging on Laravel Nested Transactions but still i am very confused , Basically in my code i have a one calling function which called multiple other functions and called functions becomes calling and they called other multiple functions etc eg
public function A()
{
$this->B();
$this->C();
}
public function B()
{
$this->D();
$this->E();
}
public function C()
{
$this->F();
}
the thing i want to achive is that whenever DB exception occur i want to rollback all the transactions in calling and called functions, so i just want to know where i have to begin transactions and end, mean weather i should begin transaction in each individual function or at root function and also how to pass exception from called function to calling function, hope so you guys will get my point
Upvotes: 0
Views: 717
Reputation: 17216
Why not simply do
public function A()
{
$this->D();
$this->E();
$this->F();
}
that way you can put DB::transaction(function ...)
on all 3 A()
, B()
and C()
Upvotes: 1