<?php
defined('_WPBOOKINGPRO_EXEC') or die;
if(!class_exists("WpBookingPro_StateController")) {
    /**
     * Class WpBookingPro_StateController
     */
    class WpBookingPro_StateController extends woobookingControllerList
    {
        /**
         * @var string
         */
        public $modelItem = "state";
        /**
         * @var string
         */
        public $modelList = "states";

        /**
         * @return mixed
         * @throws Exception
         */
        public function ajax_add_new_state()
        {
            return self::view("state.form");
        }

        /**
         * @return mixed
         * @throws Exception
         */
        public function ajax_get_item()
        {
            return self::view("state.form");
        }

        /**
         * @return bool
         * @throws Exception
         */
        public function ajax_delete()
        {
            $stateModel = WoobookingModel::getInstance('state');
            $input = Factory::getInput();
            $list_delete_state_id = $input->get('list_delete_state_id', array(), 'array');
            foreach ($list_delete_state_id as $state_id) {
                $stateModel->delete($state_id);
            }
            return true;
        }
    }
}
?>