load->model( $models ); $this->load->library( $libraries ); } public function index() { } public function getAllOffers( $projectID, $archive = 'F' ) { $offers = Offer::getAllOffers( $projectID, $archive ); $this->json( $offers ); } public function saveOffer() { $offerValidation = new OfferValidation(); if ( ! $offerValidation->getValidationResult() ) return $this->json( [ 'success' => FALSE, 'messages' => $offerValidation->getErrorMessages()] ); $offer = $this->input->post(); $offerID = $offer['id']; unset( $offer['id'] ); $offerID = Offer::saveOffer( $offerID, $offer ); $this->json( ['success' => TRUE, 'offerID' => $offerID] ); } public function archiveOffer( $offerID, $status ) { Offer::whereId( $offerID )->update( ['archive' => $status] ); } public function removeOffer( $offerID ) { $removeOffer = new RemoveOffer( $offerID ); if ( $removeOffer->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] ); Offer::removeOffer( $offerID ); $this->json( ['result' => TRUE] ); } }