outl1ne / nova-settings

A Laravel Nova tool for editing custom settings using native Nova fields.
MIT License
273 stars 97 forks source link

Default initial values for settings #64

Closed cja-github closed 3 years ago

cja-github commented 3 years ago

Hi, How can I specify default initial values for settings so that when a user looks at them before they have been set manually, they see the default values?

mstaack commented 3 years ago

Simply write a migration which insert records into the settings table

Tarpsvo commented 3 years ago

Hi! Yes, @mstaack is correct. If you truly want default values, you should insert them to your settings table. There's no good optimized way to do that otherwise. If I wanted to make ->default() work that way, the settings package would have query the settings from the database on each startup and then insert them if they're missing. That's a lot of useless queries. It's easier to just migrate them into the database and it'll be done.