<?php namespace App\Controllers;
use \App\Andy\Andymodel;
use \Forms\Form1;
use \App\Andy\BlogModel;
use CodeIgniter\I18n\Time;



class Home extends BaseController


{
	
protected $theTitle;
protected $theBlog;	
protected $date;	
protected $myDate;
protected $myTime;

				 public function __construct() 
				    {
								parent::__construct();
						  $this->myTime = parent::getTime();
						$this->myDate= date("d/m/Y",$this->myTime); 	
					
			       }
	
	
	
	public function Index()
	{
		
		




		
		//$this->cachePage(DAY);
		//got above from foundations book
		
		$data = [
                'title'  => 'home page ',
                'date'=>$this->myDate
		];
		
		
       echo view('home',$data);
      
		
	}
	
	public function oldIndex()
	
	{
	 $handle = new BlogModel();
	    $result= $handle->isEmpty();
	    
	    if ($result==NULL)
	    {
	   $data = [
                'title'  => 'landing pages',
		];
		
		 echo view('header', $data);
        echo view('home2');
        echo view('footer');	
		   
	    }
	
	
	else{
	
	 $handle = new BlogModel();
	  $result=$handle->getSome();
	  $one=$handle->getOne();
	  $date=     date("d-m-Y ");
	  
	  
	
	
	
	$data = [
                'title'  => 'landing page ss',
               //'result2'=>$resultr_dum
	       //above works
	       'result1'=>$one,
	       'result2'=>$result,
	       'date'=>$date
	       
	       
	       
	       
        ];

        echo view('header', $data);
        echo view('home', $data);
        echo view('footer',$data);	
	
	
	
	
	
	}
	}
   public function some()
   {
	 
	 
	 $handle = new BlogModel();
	  $result=$handle->getSome();
	  
	  foreach ($result as $stuff)
	  
	  {
	  
	  echo $stuff['title'];
	  
	  }
	  
	  
	   
	echo "i am home controller, function some";
	 
	
	}   
       
       
       
	public function test()

	{
	echo "now testting to delete blog entry";
	$handle= new BlogModel();
	$handle->deleteOne(120);
	}
		

      








}
