Reputation: 27
I have language table in my database that contains list of available languages:
id|language
1|en
2|de
3|lv
4|de
....
I want to load array a list with available languages in my app/config/app.php file and add it as additional parameter:
'languages' => array('en', 'ru', 'lv', 'de'…..)
Is there some proper way how to do it?
Upvotes: 1
Views: 656
Reputation: 152860
It is possible for sure. You can use Config::set('app.languages', array('en', 'ru', 'lv', 'de'…..))
to set the config dynamically. Doing it directly in the config file won't work, since all the database classes aren't available at that time.
Why even bother using the config?! In my opinion, config files are for static config that get's set inside files. And I wouldn't mix it with config data loaded from the database. Instead I would create a model Language
class Language extends Eloquent {
// this assumes your table is called "languages"
}
To get your array of languages, just do
Language::all()->lists('language');
Upvotes: 1