Laravel-Backpack/Settings

[Feature req] Define fields in config file (PHP)

tabacitu opened this issue · 3 comments

@eduardoarandah was saying on Gitter:

Settings manager should default from a regular config/settings file
Because adding settings to a production app is pain
No only settings values, also fields definitions.
Right now, code goes to repository and settings fields definitions don’t because they live in database.
Defaulting from regular config file also gives us the power of .env file, caching, etc

At first I didn’t agree, but now I think he may be onto something. It would be A LOT easier to define each Setting in PHP, not JSON in the db. Then Setting::get() would get the value from the DB, if it exists, otherwise it would fall back to the default in the configuration file.

Yes. Exactly that.
Simply overriding config/settings.php file

Also config/settings.php has the power to default to .env file and being cached

@tabacitu I think that would be a great addition to this -- somewhat underused package. It would make changing settings a breeze -- with a 'default' being created/added/generated by the developer -- and also allowing the 'managers' to be able to change the settings on the fly. I'm guessing a little work could be do to further extend this say to even provide you with markdown templates (ie: welcome email, password reset wording and so on);

Just my 2 cents :)

This isn't exactly what the original author was looking for but I have a little code that overrides the PHP config files from the database on boot. It's dependent on this pull request (#91) but I can post an example if it would be useful.