I am having trouble loading model in sub module controller from sub module itself.
I am having few modules and sub-modules as below
modules/admin/
modules/admin/models
modules/admin/controllers
modules/admin/views
modules/admin/models/dashboard/
modules/admin/controllers/dashboard/
modules/admin/views/dashboard/
modules/admin/models/plugs/
modules/admin/controllers/plugs/
modules/admin/views/plugs/
Each M/V/C has own files in it.
Now I have created model in modules/admin/models/plugs/ just for testing purpose something like below
Plugs Model
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Plugs extends CI_Model
{
public function __construct()
{
parent::__construct();
}
public function mymeta()
{
return 'plugs model loded';
}
}
And now trying to load into Plugs Controller as below
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');
class Plugs extends MX_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('plugs');
}
public function index()
{
$this->load->view('plugs/index');
}
public function get_plugin_meta()
{
echo $this->plugs->mymeta(); // this is the method from Plugs Models
}
}
But when I tried to access the URL http://localhost/mysite/admin/plugs/get_plugin_meta
or http://localhost/mysite/admin/plugs
it is giving me below error.
An Error Was Encountered
Unable to locate the model you have specified: plugs
So than how to load model in controller?