@@ -31,11 +31,12 @@ public function payFreeCart(Cart $cart): array
3131 app (CommonService::class)
3232 ->verifyWithdraw ($ this , 0 );
3333
34- return DB ::transaction (function () use ($ cart ) {
34+ $ self = $ this ;
35+ return DB ::transaction (static function () use ($ self , $ cart ) {
3536 $ results = [];
3637 foreach ($ cart ->getItems () as $ product ) {
3738 $ results [] = app (CommonService::class)->forceTransfer (
38- $ this ,
39+ $ self ,
3940 $ product ,
4041 0 ,
4142 $ product ->getMetaProduct (),
@@ -73,12 +74,13 @@ public function payCart(Cart $cart, bool $force = null): array
7374 throw new ProductEnded (trans ('wallet::errors.product_stock ' ));
7475 }
7576
76- return DB ::transaction (function () use ($ cart , $ force ) {
77+ $ self = $ this ;
78+ return DB ::transaction (static function () use ($ self , $ cart , $ force ) {
7779 $ results = [];
7880 foreach ($ cart ->getItems () as $ product ) {
7981 if ($ force ) {
8082 $ results [] = app (CommonService::class)->forceTransfer (
81- $ this ,
83+ $ self ,
8284 $ product ,
8385 $ product ->getAmountProduct (),
8486 $ product ->getMetaProduct (),
@@ -89,7 +91,7 @@ public function payCart(Cart $cart, bool $force = null): array
8991 }
9092
9193 $ results [] = app (CommonService::class)->transfer (
92- $ this ,
94+ $ self ,
9395 $ product ,
9496 $ product ->getAmountProduct (),
9597 $ product ->getMetaProduct (),
@@ -135,12 +137,13 @@ public function safeRefundCart(Cart $cart, bool $force = null, bool $gifts = nul
135137 */
136138 public function refundCart (Cart $ cart , bool $ force = null , bool $ gifts = null ): bool
137139 {
138- return DB ::transaction (function () use ($ cart , $ force , $ gifts ) {
140+ $ self = $ this ;
141+ return DB ::transaction (static function () use ($ self , $ cart , $ force , $ gifts ) {
139142 $ results = [];
140- $ transfers = $ cart ->alreadyBuy ($ this , $ gifts );
143+ $ transfers = $ cart ->alreadyBuy ($ self , $ gifts );
141144 if (count ($ transfers ) !== count ($ cart )) {
142145 throw (new ModelNotFoundException ())
143- ->setModel ($ this ->transfers ()->getMorphClass ());
146+ ->setModel ($ self ->transfers ()->getMorphClass ());
144147 }
145148
146149 foreach ($ cart ->getItems () as $ key => $ product ) {
0 commit comments