<?php

namespace WpBookingHotelFrontend\app\controllers;

use WpBookingHotel\Factory;
use WpBookingHotel\Filesystem\Support\StringController;
use WpBookingHotel\Mvc\Controller\ControllerFrontend;
use WpBookingHotel\Mvc\Model\Model;
use WpBookingHotel\Utilities\Utility;
use WpBookingHotelFrontend\app\helpers\ConfigHelper;
use WpBookingHotelFrontend\app\helpers\EmailHelper;

defined('_WPBOOKINGHOTEL_EXEC') or die;

/**
 * Class BlockController
 */
class WishlistController extends ControllerFrontend
{
    function change_wishlist(){
        $modelWishlist = Model::getInstance('wishlist');
       
        $input = Factory::getInput();
        $hotel_id = $input->getInt('hotel_id',0);
        $user_id=  $input->getInt('user_id',0);
        $db=Factory::getDBO();
        $query = $db->getQuery(true);
            $query->clear()
                ->select('wishlist.*')
                ->from(Utility::getTableName('wishlist') . ' AS wishlist')
                ->where('wishlist.hotel_id='.(int)$hotel_id)
                ->where('wishlist.user_id='.(int)$user_id);
    
    
        $list =  $db->setQuery($query)->loadObjectList();
        
        if(count($list)>0){
            $query = $db->getQuery(true);
            $query->clear()
                ->delete(Utility::getTableName('wishlist'))
                ->where('hotel_id='.(int)$hotel_id)
                ->where('user_id='.(int)$user_id);
               
                $db->setQuery($query)->execute();
    
        }else{
            echo 'string';
            $query = $db->getQuery(true);
            $query->clear()
            ->insert(Utility::getTableName('wishlist'))
            ->set('hotel_id='.(int)$hotel_id)
            ->set('user_id='.(int)$user_id);
    
            $db->setQuery($query)->execute();
    
           
        }
        die;
        return [];
       }

}
