This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I have made a Middleware that switches the credentials of the default database and re-connects it. This works great with most models, however the site's settings (I.E. enabled plugins) continue to be retrieved/updated from the original database instead of the new connection.
Is there someway to tell the settings manager to refresh it's values?
This is likely to be caused by the fact that Settings models are cached in memory and do not expect the data source to be changed.
Log an issue for it on GitHub, we may need to introduce a feature for it. Something along the lines of SettingsModel::flushInstances()
.
Thanks for the quick reply. I figured that would be the answer. I have been working with Laravel for about a year now, but I'm still by far no expert.
I am a full time Jr. Developer, and my Sr. has recently decided for me to start using October as a starting point. So I'll be doing a lot of development for October. So I'll be around the forums. I'll offer help where I can.
I would like, and my employer agrees, to add some plugins to the marketplace once stable.
We would need to have a more private discussion before this happened though, regarding licenses on the marketplace. (If you get where I am going with this) There seems to be no private messaging system, and I can't find an email address anywhere. Perhaps you could email me at my registered address?
I will create the issue on GitHub, though. It would be much appreciated. Thanks.
Just to follow up, the Issue was posted and was not only implemented, it was done via live stream. Awesome, thank you guys a million.
Unfortunately, it did not solve my issue. There were no instances yet. I drove myself nuts dumping data here and there, looking at the model's connection as it should have been.
The problem was so simple it was ridiculous. Eloquent caching. Apparently a newer feature of Laravel not well documented, you had cached the settings records on Eloquent models with a simple ->remember() in the query. Since the default method of caching is a file, it was keeping records after I had switched the database connection.
Really, all I needed was to Cache::flush(). But upon further contemplation, I decided to change my logic and use Dotenv to load the connection information dynamically before the app even boots instead of having the overhead of re-connecting.
Thus, changing the cache driver to database solved my issue entirely. The correct credentials are loaded from the start and then the cache works off of that database. Perfect.
This may help someone else.
Looking forward to doing magic with October. ;)
1-4 of 4