Sorry if the question has already been asked, but I have wanted to know if import a model in another model MVC is correct or whether it is best to do the same function in EVERY models?
For now in the Model in my Library folder I add the same method as in my Controller:
class Model
{
protected function __construct()
{
$this->db = new Database;
}
public function model($model)
{
require_once '../app/models/' . $model . '.php';
return new $model();
}
}
And in my model file :
class Exemple_model extends Model
{
function __construct ()
{
parent::__construct();
}
public function exemple_function()
{
$otherModel = $this->model('urlAnotherModelFile');
$otherModel->otherMethod();
}
}
But I am not sure it is correct to do so or if is the best way.
Thank you in advance for your answers.