Welcome Guest, Not a member yet? Register   Sign In
Include model inside a model
#1

Hello! We are finally ready to use CodeIgniter 4. I only have some problems with using a model inside a model. I was expecting that I could use something like this:

PHP Code:
namespace App\Models;
use 
CodeIgniter\Model;
class 
Filters_model extends Model {

    function __construct(){
        // Call the Model constructor
        parent::__construct();
        $this->session session();
        $this->customers model('Customers_model');
    }



But that doesn't seems to work. I'm getting a "Service Temporarily Unavailable" error. In CI3 you could just put it in autoload and use it wherever you like.

How can I include a model inside a current model to use those functions of that model?
Reply
#2

Conceptually that should work fine! I believe your actual error is hiding because you are in a production instance. Try checking your error logs or switching the environment to “development” and share the actual issue.
Reply
#3

(06-19-2021, 06:12 AM)MGatner Wrote: Conceptually that should work fine! I believe your actual error is hiding because you are in a production instance. Try checking your error logs or switching the environment to “development” and share the actual issue.

Thanks for your reply. I've checked in the index.php. The environment is in development.
Reply
#4

Rename env file to. env


CI_ENVIRONMENT = production

To development

Remove # too
Enlightenment  Is  Freedom
Reply




Theme © iAndrew 2016 - Forum software by © MyBB