<?php namespace App\Controllers;
use CodeIgniter\Controller;
use CodeIgniter\I18n\Time;




    class Pages extends BaseController 
    {
    protected $logic1;
    protected $logic2;
    protected $myTime;

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


    			public function index()
				{
					
					 echo $this->request->getVar('title');
					//return view('welcome_message');
				}

						public function showme($page = 'home')
					    {
							$this->logic1=	file_exists(APPPATH.'/Views/'.$page.'.php');
								
											if(( $this->logic1 == NUll)OR ($this->logic1 == False))
											
											{
											
											return redirect('noPage');
										  //throw new \CodeIgniter\Exceptions\PageNotFoundException($page);		
												
										   }														
											elseif(($this->logic1==1)OR($this->logic1==true))
											{
												
												$data = [
														'title'  =>ucfirst($page)	 ,
														'date'=>$this->myDate
												];
												
																			
										
										
											echo view($page,$data);
											
											
										
									}
									
									
									
										
										
										}	
												
												
						
					
			
    public function nopage()
    {
    
	
	$data = [
                'title'  => 'no page',
               //'result2'=>$result
	       //above works
	       
	       'date'=>$this->myDate
	       
	       
	       
	       
        ];

     
        echo view('noPage',$data);
       
	
   
   
   
   
    }
    
 }   
    
    
    
    
