Exemplo n.º 1
0
 public static function createNewWishlist($input)
 {
     $user_id = Session::get('user_id');
     $error_code = ApiResponse::OK;
     $wishlist = new Wishlist();
     $wishlist->user_id = $user_id;
     if (!empty($input['wine_unique_id'])) {
         $wishlist->wine_unique_id = $input['wine_unique_id'];
         $wine_wishlist = Wishlist::where('wine_unique_id', $wishlist->wine_unique_id)->where('user_id', $user_id)->first();
         if ($wine_wishlist) {
             $error_code = ApiResponse::DUPLICATED_WISHLIST_ADD;
             $data = ApiResponse::getErrorContent(ApiResponse::DUPLICATED_WISHLIST_ADD);
         } else {
             $wishlist->save();
             $data = $wishlist->toArray();
         }
     } else {
         $error_code = ApiResponse::MISSING_PARAMS;
         $data = $input;
     }
     return array("code" => $error_code, "data" => $data);
 }