public function add_hotel() { $data = $_POST; $resp = new ajax_response(); $hotel = new Hotel(); if (!empty($data)) { $result = $hotel->update_hotel($data['hotel'], null, 'add'); } if (is_int($result)) { $hotel = new Hotel($result); $resp->set_status(true); $resp->set_message($hotel->hotel_name . ' added successfully.'); } else { $resp->set_status(false); $resp->set_message('Could not add ' . $hotel->hotel_name . '. Please try again.'); } echo $resp->encode_response(); die; }