Welcome Guest, Not a member yet? Register   Sign In
can't create instance of a model class in models from controller class
#3

@InsiteFX cheers for the heads  up


in my controller Home.php(in Controller dir ) i have

PHP Code:
<?php namespace App\Controllers;
 use 
App\Models\NewsModel;
 

class 
Home extends BaseController
{
    public function index()
   
    
{
       
     $model 
= new NewsModel();  

    then in my model NewsModel.php (in Models dir) I have
PHP Code:
<?php namespace  App\Models


class 
NewsModel 


{
       public function index()
       
       
{
        
   
           
       



i don't want to extend any class , connect to a databse or anything else ,just get system to find class

Now if i understand Namespace & use correctly because i stated full namespace in controller

PHP Code:
use App\Models\NewsModel;

then i should be able to use short code 
PHP Code:
$model = new NewsModel();   

i just dont get it 
i wonder if its some sort of autoload issue or something else in system 
Reply


Messages In This Thread
RE: can't create instance of a model class in models from controller class - by captain-sensible - 11-12-2019, 09:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB