• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Global model


In CI3 i have one model that i have used as my main model (he holds all config, useful functions, there was html title of the page and other stuff) in any other model, controller or even view i can call this model and use functions or set properties.

Now in CI4 i have problem with this. My question is: How to make one model that is visible under all models? Is there any solution to not to load my model any time when i want to use it ?
There is solution for one "main model" that is visible to all models?

Thank you for reply

A couple of ideas:

1. You could extend all models from your own BaseModel that instantiates that other model and makes it available.
2. You could create a Service for that model so that only a single instance is always loaded whenever you call it.

Though, honestly, it sounds like that should be a library not a model, if you ask me.
Support Development  • Practical CodeIgniter 3  •
Myth:AuthVulcan - CLI Tools for CI4

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.