Model + Services - 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: Model + Services (/showthread.php?tid=78409) |
Model + Services - okatse - 01-15-2021 Documentation says Quote:It is recommended to only create services within controllers. Other files, like models and libraries should have the dependencies either passed into the constructor or through a setter method. In Services.php i have 6 such methods as PHP Code: public static function permissions($getShared = true) I have to write in every model PHP Code: class SomeModel extends Model { RE: Model + Services - paulbalandan - 01-15-2021 In your Model's constructor, no need to pass the services as arguments. You can just call $this->permissions = Services::permissions(); Do the same with the others you need. |