public function addToSlider() { $http = new Http(); $return = array(); $id = $http->post('id_new_product'); if (!empty($id)) { $slider_m = new Slider(); $slider_m->setProductId($id); $slider_m->writeData(); $product = new Product($id); $return['id'] = $id; $return['name'] = $product->getName(); $return['img'] = $product->getImage(); $return['price'] = $product->getPrice(); } echo json_encode($return); }