I was looking for a way to change the .env-values within a controller or from something else. I found nothing, so I created my own little method.
It takes an array of new values. The array key must be the key from the .env.
The script overwrites the old .env. Yet not perfect, but works for now.
UPDATE: I am developing a package which will provide this functionality in a better way. The package will ship with some more features.
UPDATE: Here is the Link to the Package: https://github.com/Brotzka/laravel-dotenv-editor. Give it a try ;) There will be more features in a few days.