Offers
This commit is contained in:
@@ -11,6 +11,8 @@ class OffersController extends MY_Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if ( AUTHENTICATED == FALSE ) die( 'NO ACCESS' );
|
||||
|
||||
$models = [];
|
||||
@@ -27,41 +29,41 @@ class OffersController extends MY_Controller {
|
||||
|
||||
public function getAllOffers( $archive = 'F' )
|
||||
{
|
||||
$users = Offer::getAllOffers( $archive );
|
||||
$offers = Offer::getAllOffers( $archive );
|
||||
|
||||
$this->json( $users );
|
||||
$this->json( $offers );
|
||||
}
|
||||
|
||||
public function saveOffer()
|
||||
{
|
||||
$userValidation = new OfferValidation();
|
||||
$offerValidation = new OfferValidation();
|
||||
|
||||
if ( ! $userValidation->getValidationResult() )
|
||||
if ( ! $offerValidation->getValidationResult() )
|
||||
return $this->json( [
|
||||
'success' => FALSE, 'messages' => $userValidation->getErrorMessages()] );
|
||||
'success' => FALSE, 'messages' => $offerValidation->getErrorMessages()] );
|
||||
|
||||
$user = $this->input->post();
|
||||
$offer = $this->input->post();
|
||||
|
||||
$userID = $user['id'];
|
||||
unset( $user['id'] );
|
||||
$offerID = $offer['id'];
|
||||
unset( $offer['id'] );
|
||||
|
||||
$userID = Offer::saveOffer( $userID, $user );
|
||||
$offerID = Offer::saveOffer( $offerID, $offer );
|
||||
|
||||
$this->json( ['success' => TRUE, 'userID' => $userID] );
|
||||
$this->json( ['success' => TRUE, 'offerID' => $offerID] );
|
||||
}
|
||||
|
||||
public function archiveOffer( $userID, $status )
|
||||
public function archiveOffer( $offerID, $status )
|
||||
{
|
||||
Offer::whereId( $userID )->update( ['archive' => $status] );
|
||||
Offer::whereId( $offerID )->update( ['archive' => $status] );
|
||||
}
|
||||
|
||||
public function removeOffer( $userID )
|
||||
public function removeOffer( $offerID )
|
||||
{
|
||||
$removeOffer = new RemoveOffer( $userID );
|
||||
$removeOffer = new RemoveOffer( $offerID );
|
||||
|
||||
if ( $removeOffer->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
|
||||
|
||||
Offer::removeOffer( $userID );
|
||||
Offer::removeOffer( $offerID );
|
||||
|
||||
$this->json( ['result' => TRUE] );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user