/** * Override save method to add the image processing */ public function save($data) { // perform default save $save = parent::save($data); if (!$save) { return false; } // save or delete image $imageHelper = new CHPanelHelperImage(JComponentHelper::getParams('com_chpanel')); $file = $_FILES['image']; if ($file['size']) { $imageHelper->uploadImage($file, $this->getState('room.id'), 'rooms'); } else { if (JRequest::getInt('image_delete')) { $imageHelper->deleteImage($this->getState('room.id'), 'rooms'); } } return true; }
/** * Extend save method to add the image and tag processing */ public function save($data) { // joomla save $save = parent::save($data); if (!$save) { return false; } // get the hotel id $hotel_id = $this->getState('hotel.id'); if (!$hotel_id) { return false; } // save or delete image $imageHelper = new CHPanelHelperImage(JComponentHelper::getParams('com_chpanel')); $file = $_FILES['image']; if ($file['size']) { $imageHelper->uploadImage($file, $hotel_id, 'hotels'); } else { if (JRequest::getInt('image_delete')) { $imageHelper->deleteImage($hotel_id, 'hotels'); } } return true; }