Procházet zdrojové kódy

修改礼品卡接口

llp před 1 týdnem
rodič
revize
a1279719fb

+ 4 - 3
packages/Longyi/Gift/src/Http/Controllers/Shop/GiftController.php

@@ -15,7 +15,8 @@ use Longyi\Gift\Http\Resources\CustomCartResource;
 class GiftController extends Controller
 {
     public function __construct(
-        protected GiftCardsRepository $giftCardRepository
+        protected GiftCardsRepository $giftCardRepository,
+        protected GiftCards $giftCardsModel
     ) {
     }
 
@@ -27,7 +28,7 @@ class GiftController extends Controller
 
     public function lists(): JsonResponse
     {
-        $gifts = $this->giftCardRepository->giftcards();
+        $gifts = $this->giftCardsModel->giftcards();
         return response()->json([
             'success' => true,
             'data' => $gifts,
@@ -37,7 +38,7 @@ class GiftController extends Controller
     public function add($request): JsonResponse
     {
         $id = $request->input('id');
-        $success = $this->giftCardRepository->add($id);
+        $success = $this->giftCardsModel->add($id);
         return response()->json([
             'success' => $success,
             'message' => $success ? 'Gift card added successfully' : 'Failed to add gift card',

+ 1 - 1
packages/Longyi/Gift/src/Models/GiftCards.php

@@ -179,7 +179,7 @@ class GiftCards extends Model implements GiftCardsContract
     {
         $gifts = $this->giftcards();
         $giftInfo = $gifts[$id] ?? null;
-        if ($giftInfo) {
+        if (!$giftInfo) {
             return false;
         }
         try {