CodeIgniter Forums
Custom chaining in codeigniter4 model - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: Custom chaining in codeigniter4 model (/showthread.php?tid=80741)



Custom chaining in codeigniter4 model - RedWd - 12-11-2021

Hi everyone, like suggested in title i would like to do somethings like this:

PHP Code:
$UserModel->Where('age','18')->WithCompanyInfo()->findAll(); 

so, in my UserModel i must create this method WithCompanyInfo that refer to another table / model CompanyModel with external key "user_id".

PHP Code:
  public function WithCompanyInfo ()
  {
    //somehow tell ci4 to make a join and retrieve companymodel info
    return $this;
  

How can be done that?
thanks

UPDATE

I've found how to manage that.