|
|
@@ -29,6 +29,7 @@ class GiftController extends Controller
|
|
|
|
|
|
public function lists(): JsonResponse
|
|
|
{
|
|
|
+ $customerId = auth()->user()->id;
|
|
|
$gifts = $this->giftCardsModel->giftcards();
|
|
|
return ApiResponse::success($gifts);
|
|
|
}
|
|
|
@@ -60,10 +61,8 @@ class GiftController extends Controller
|
|
|
->where('expirationdate', '>=', now())
|
|
|
->orderBy('created_at', 'desc')
|
|
|
->get();
|
|
|
-
|
|
|
- return response()->json([
|
|
|
- 'success' => true,
|
|
|
- 'data' => $giftCards->map(function ($giftCard) {
|
|
|
+ return ApiResponse::success(
|
|
|
+ $giftCards->map(function ($giftCard) {
|
|
|
return [
|
|
|
'id' => $giftCard->id,
|
|
|
'giftcard_number' => $giftCard->giftcard_number,
|
|
|
@@ -72,16 +71,12 @@ class GiftController extends Controller
|
|
|
'formatted_remaining_giftcard_amount' => core()->formatPrice(core()->convertPrice($giftCard->remaining_giftcard_amount)),
|
|
|
'used_giftcard_amount' => $giftCard->used_giftcard_amount,
|
|
|
'expirationdate' => $giftCard->expirationdate->format('Y-m-d'),
|
|
|
- 'giftcard_status' => $giftCard->giftcard_status,
|
|
|
+ 'giftcard_status' => $giftCard->giftcard_status
|
|
|
];
|
|
|
- }),
|
|
|
- ]);
|
|
|
+ })
|
|
|
+ );
|
|
|
} catch (\Exception $e) {
|
|
|
- return response()->json([
|
|
|
- 'success' => false,
|
|
|
- 'message' => 'Failed to fetch gift cards',
|
|
|
- 'error' => $e->getMessage(),
|
|
|
- ], Response::HTTP_INTERNAL_SERVER_ERROR);
|
|
|
+ return ApiResponse::error($e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
/**
|