Question: I need to store some global variables for my laravel website, but I need to update them programmatically. Here is my situation:

[![Part of my admin dashboard, the admin can enable popups when a visitor comes to the website.](https://i.stack.imgur.com/zxK5I.png)](https://i.stack.imgur.com/zxK5I.png)

the admin should be able to enable popups, and configure which post it has to link, which will show when a visitor comes to the website.

**Other answers and why they did not satisfy me.**

* Making a laravel config file.
* A database table.
* Static variable somewhere in a controller or model.

A **Laravel config file** seemed to be the best option at first, but it didn't fit with the need to update them at running time. I've readt answers that suggested to call an artisan cache clear in the controller in order to update the values. but this seems just off to me. I don't think its a good idea to mess with the cache like that.

A **database** is still an option, however, it has some downsides as well. Making just an SQL table for 2 config variables seems like a waste of tables, it also means i need to make 2 query's on the admin dashboard, and also 1 on the homepage (to get the popup config), which i rather keep database-free.

A **static variable in a model or controller**. I saw this suggestion as well altough noted: it is probably a very bad design choice. Nevertheless i tried it in a desperate attempt and it didnt work. It did not stay updated on page reload.

I'm a laravel noob in case you didn't notice. Is there anything I am doing or understanding wrong? Or is there a solution I am not aware of?

*There is no need for me to save the variable when the website is offline. It would be nice if it did but its only a minor inconvience for the admin to set it on restart.*

Answer: 
For your situation, spatie write a nice [package](https://github.com/spatie/laravel-settings).

Just install as in documentation and use.
You can set config values dynamically at runtime with [`config()`](https://laravel.com/docs/5.2/helpers#method-config) helper:

```
config([ 'app.popup1' => true ]);

```

Another solution is to write the config value into [session](https://laravel.com/docs/5.2/helpers#method-session) at startup and only update the session:

```
session([ 'app.popup1' => true ]);

```