Is there a tutorial on how to save global settings for app? I would need to save a few simple true/false (on/off) settings, and one setting should be a list of emails which will get notifications when cron job finishes. I have seen this https://laracasts.com/lessons/managing-mass-user-settings but this stores data as a separate column for user. I have found out this http://culttt.com/2015/02/02/storing-user-settings-relational-database/ which recommends "Property bag", this seems ok because I could add new settings later when needed.
Is this the type of options storing that Wordpress uses?
Thank you, I have tried it and it works nice, but these configuration settings aren't meant to be changed in user interface right?
I would prefer if I could save the values in database so I can adjust them when needed and not manually change values in the file
Then it's just to create a table with couple of columns, i.e. key and value and save your options. Create a model for the table and you're set. If you don't want to query the database on every request, you could store the options in the session or cache them.
@SaeedPrez using the database does really seem to be an ideal solution. However, I'm not sure about having a table with key and value columns only?.
I mean, yes it makes the process of adding a global setting as well as removing one a cinch. On the other hand, it means you have no idea what global settings you may or may not have? So you can basically make a dynamic form that iterates through the table you have and echo a form input for each setting you have but what if some setting should be a date and you want to assist the user by showing a date picker? What if you want a text area for some setting? Maybe an email type input? Phone type input? If you want that kind of flexibility, there are 2 options I see for that:
Have a type column that will indicate the type of input for the setting or make it represent the markup for the input itself?
Make each setting a column and have only 1 row in your table. This way, you can expect what settings are there going to be.
I would need to save a few simple true/false (on/off) settings, and one setting should be a list of emails which will get notifications when cron job finishes.
One thing I've learned that has probably helped me the most when it comes to actually releasing projects, it is to build things as simple as possible until there is a need for more advanced solutions..
With that said, I suggested a couple of simple ways for what I believe is a simple need and @filaret is free to add more complexity if he/she wants/needs to.
In the end I have created new table for emails and separate table for options column. I couldn't find any tutorial regarding this "Property bag" setup, so a possibility to have multiple emails written in one column field while in the view showing that every email as separate input seemed like too much spaghetti code...