コード例 #1
0
 public function updateProductImageType(Request $request)
 {
     $productId = $request->input('productId');
     $imageId = $request->input('imageId');
     $action = $request->input('action');
     $productGallery = new productGalleryModel();
     $productGalleryService = new productGalleryService();
     $return['ok'] = 0;
     try {
         $image = $productGallery->getImageById($imageId);
         if ($action == 'setPrimaryImage') {
             $return['data'] = $productGallery->setPrimaryImage($imageId, $productId);
         } elseif ($action == 'deleteImage') {
             $productGalleryService->deleteImage($imageId);
             $return['data'] = true;
         } elseif ($action == 'setSlideImage') {
             $return['data'] = $productGallery->setSlideImage($imageId);
         }
         $return['ok'] = 1;
     } catch (\Exception $e) {
         // @codeCoverageIgnoreStart
         $return['errorMsg'] = $e->getMessage();
         // @codeCoverageIgnoreEnd
     }
     return response()->json($return);
 }