CodeIgniter Forums
Extending existing user model - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10)
+--- Thread: Extending existing user model (/showthread.php?tid=87212)



Extending existing user model - krava - 03-26-2023

Hello
I have a problem with extending the method of existing model. 
Here is the example. The user model located in the file: /application/model/subscriptions_model.php :
Code:
class Subscriptions_model extends App_Model {
    public function __construct() {
        parent::__construct();
    }
    public function get_child_invoices($id) {
       return $child;
    }}
I'd like to extend method of the model in the new file `/application/model/my_subscriptions_model.php`.
Code:
class My_subscriptions_model extends Subscriptions_model {
    public function __construct() {
        parent::__construct();
    }
    public get_child_invoices($id) {
        return $child;
    }}
The goal is to rewrite existing method get_child_invoices  of  Subscriptions_model .
Is it possible to resolve this issue?
Or as a way to expand the subscription controller Subscriptions (/application/controllers/subscription.php) and call the another module.
Thank you.


RE: Extending existing user model - InsiteFX - 03-27-2023

If you want to extend the CodeIgniter model, it's CI_Model not app_model.