Hi,
I seem to have an odd problem here. I am not sure why this is happening. I am using version 4.1.8. The following is the problematic code:
Code:
<?php
namespace App\Controllers;
use App\Controllers\BaseController;
use APP\Models\MenuModel;
use APP\Models\UsersModel;
class TestSqlite3 extends BaseController
{
public $usersModel;
public $menuModel;
public function __construct()
{
// $this->usersModel = model("UsersModel");
// $this->menuModel = model("MenuModel");
$this->usersModel = new UsersModel();
$this->menuModel = new MenuModel();
}
public function adduser()
{
echo "hello there";
}
The models have been created and exist. When i run the code i get this error:
https://prnt.sc/3uXJTJ3ptcAv
Code:
Error
Class 'APP\Models\UsersModel' not found
APPPATH\Controllers\TestSqlite3.php at line 17
10 {
11 public $usersModel;
12 public $menuModel;
13 public function __construct()
14 {
15 // $this->usersModel = model("UsersModel");
16 // $this->menuModel = model("MenuModel");
17 $this->usersModel = new UsersModel();
18 $this->menuModel = new MenuModel();
19 }
20 public function adduser()
21 {
22 echo "hello there";
23 }
24 }
But when change the code for creating the model instance as per the following code, it seems to work ok:
Code:
<?php
namespace App\Controllers;
use App\Controllers\BaseController;
// use APP\Models\MenuModel;
// use APP\Models\UsersModel;
class TestSqlite3 extends BaseController
{
public $usersModel;
public $menuModel;
public function __construct()
{
$this->usersModel = model("UsersModel");
$this->menuModel = model("MenuModel");
// $this->usersModel = new UsersModel();
// $this->menuModel = new MenuModel();
}
public function adduser()
{
echo "hello there";
}
Appreciate any help. Thank you