• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.