Welcome Guest, Not a member yet? Register   Sign In
Global model
#1

(This post was last modified: 05-15-2019, 07:22 AM by Piotr.)

Hello

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
Reply
#2

(This post was last modified: 05-15-2019, 07:31 AM by kilishan.)

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB