I've created a Settings model and database table to contain things like email addresses, pagination limits, custom colours - all sorts of settings for the site that I don't want baked into the code.
What I want to create is a helper that loads all the settings on first use and can then be accessed anywhere in the application with just a helper like the session helper, eg setting('email.from')
You could try creating a config file (maybe config/settings.php) that returns an array of whatever you will need from the settings table. Load the values from the model in there (or even better save them in the cache) and you should be able to call config('email.from'). This article may help! This is the most straightforward way I can think of.
Then probably @skliche 's solution should work. You can create the config file inside the boot method in a service provider class like AppServiceProvider. You can probably refactor it later, since it may become ugly soon.
Wouldn't hurt to have a class with static methods for global use, of course a use statement is required. As example I use this to figure out a checkbox:
Thanks for your help guys. Sorry for the delay but I've been off having my dinner.
I decided to piggy-back on the existing config helper, with the following added to AppServiceProvider
public function boot()
{
config(['settings' => Settings::pluck('value','key')->toArray()]);
}
With a Settings table/model that has key and value columns, this gives me anywhere access to for instance; config('settings.memberPaginator') and rather than putting this in the config files, the settings can be changed through the UI.
I marked @skliche best answer because he(?) did put a lot of effort in and it was not his fault it was not used.
@jlrdw you seem to have posted an answer against the wrong question. ;-)