CodeIgniter Forums
Model in subfolder not working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: Model-View-Controller (https://forum.codeigniter.com/forum-10.html)
+--- Thread: Model in subfolder not working (/thread-81001.html)



Model in subfolder not working - Kaosweaver - 01-12-2022

In the controller:

PHP Code:
$companyListModel = new \App\Models\rt3\CompanyListModel(); 

The Models folder has an Rt3 folder with the CompanyListModel.php in it.

PHP Code:
<?php namespace App\Models;

use 
CodeIgniter\Model;

class 
CompanyListModel extends Model
{
    protected $table 'CompanyList';
    protected $DBGroup 'rt3';

    protected $allowedFields = [
      // database list here
    ];

    protected $primaryKey "id";

    protected $returnType 'App\Entities\CompanyList';




Get this error:

Code:
Class 'App\Models\Rt3\CompanyListModel' not found

What am I doing wrong?


RE: Model in subfolder not working - iRedds - 01-12-2022

<?php namespace App\Models; <- wrong namespace


RE: Model in subfolder not working - Kaosweaver - 01-13-2022

(01-12-2022, 01:36 PM)iRedds Wrote: <?php namespace App\Models; <- wrong namespace

Thank you, that worked!