Currently i am using something like this:
//at bootstrap.php file
Configure::write('from', 'mymail@mydomain.com')
//at controllers or models files
$var = Configure::read('from')
The thing is, i would like to manage that variable through the database to be able to modify it in a simpler way.
I was thinking about doing it with AppModel
but then it would only be accessible for Models and not controllers.
What should I do in this case?
Thanks.
in AppController you can write this method:
this way the getSettings() method is available in any model and any controller
any model call:
any controller call:
You can create a separate model / plugin which will be mapped to a configuration table in your database. Then load it through
$uses
statement for controllers andApp::import()
for models.Then, in your controller:
In model:
This works just fine. Of course, you might also load settings in both
AppController
andAppModel
to follow the DRY rule.