<?php

namespace Dashboard\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use \Dashboard\Form\TourTypeAddForm;



class TourTypeController extends AbstractActionController {

    
    /**
     * Index
     * @return ViewModel
     */
    public function indexAction(){
               
        
        //Call API...
        $tourTypeListing = [
            '0'=>[
                'tour_type_id'=>'1',
                'tour_type_name'=>'Sea Beatch'                
            ],
            '1'=>[
                'tour_type_id'=>'2',
                'tour_type_name'=>'Forest'                
            ],
            '2'=>[
                'tour_type_id'=>'3',
                'tour_type_name'=>'Adventure or Sporting'                
            ]            
        ];
      
        $viewModel = new ViewModel(['tourTypeListing'=>$tourTypeListing]);
        return $viewModel;
    }
    
 public function addTourTypeAction(){
     
     $form = new TourTypeAddForm();
     
     //$this->url('tour-type', ['action' => 'add-tour-type']
      $request = $this->getRequest();        
        //if request will be post                
        if($request->isPost()){
            $form->setData($request->getPost());                        
            if($form->isValid()){                 
                $post = $request->getPost()->toArray();
               
                return $this->redirect()->toRoute('tour-type',  ['action'=>'add-tour-type']);    
                
               }
               else{
            //$aa =   $form->getMessages();
            //echo "<pre>";print_r($aa); exit;
                   
           
        }
               
        }
     
      $viewModel = new ViewModel(['form'=> $form]);
        return $viewModel;
     
 }
 
 public function editTourTypeAction(){
     
     $form = new TourTypeAddForm();
     
      $viewModel = new ViewModel(['form'=> $form]);
        return $viewModel;
     
 }
 
}
