public function setFavDish() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $json = array(); $json['status_code'] = 1; $id_dish = isset($_GET['id_dish']) ? addslashes($_GET['id_dish']) : ""; if (!$id_dish) { $json['status_code'] = 0; $json['status_message'] = "No ID Found"; echo json_encode($json); die; } $objDish = new MasterDishModel(); $arrDish = $objDish->getWhere("id_dish = '{$id_dish}'"); MasterDish::checkCountWithMsg($arrDish, "ID Dish not found!"); foreach ($arrDish as $val) { $val->fav = $val->fav + 1; $val->load = 1; $id_restaurant = $val->id_restaurant; } if ($id_restaurant != "") { $objResto = new MasterRestaurantModel(); $arrResto = $objResto->getWhere("id_restaurant='{$id_restaurant}'"); MasterDish::checkCountWithMsg($arrResto, "ID Resto not found!"); $idDish = $arrDish[0]->save(); if (!$idDish) { self::errorMsg("Favorite Dish" . Lang::t('save failed')); } $arrResto[0]->fav = $arrResto[0]->fav + 1; $arrResto[0]->load = 1; $saveResto = $arrResto[0]->save(); if (!$saveResto) { self::errorMsg("Favorite Resto" . Lang::t('save failed')); } } $json['status_message'] = 'Success'; echo json_encode($json); die; }