Brotzka
Brotzka

Reputation: 2785

Laravel 5.2 can not set config value

I have the problem that I can not set my configuration values through the config() function.

I have my own config file (cms.php in config/). The value I want to change is 'index'.

In my ConfigController I try to set the value with this:

config(['cms.index' => $page_id]);

Any solutions? Do I have to import a special class?

Upvotes: 0

Views: 9064

Answers (2)

Muhammet
Muhammet

Reputation: 3308

config(['cms.index' => $page_id]); will set the value for runtime only. It won't save it to the config file.

If you want persistent configurations take a look at Update Config on Runtime Persistently

Upvotes: 6

oseintow
oseintow

Reputation: 7371

Change it to \Config::set('cms.index', $page_id);

Upvotes: 1

Related Questions