Adding Settings
Last updated
Last updated
You can easily add more settings fields in config/hotcoffee/settings.php. However you will need to first publish this configuration file:
php artisan vendor:publish --tag=hotcoffee_config_settings
Inside of the "fields" array you can specify new sections and fields in those sections:
Say you want to create a new group (or section) of settings in the admin panel:
Each array inside represents a field:
name Keyword. The value of this setting will be called with settings('my_setting').
label The label for the field.
field_type The type of the field. Can be text, textarea, number, checkbox, radio, select and toggle.
icon Icon code for the field.
info_text This text will appear bellow the field. Use it to explain where/how the setting is used.
required If true, required attribute will be added to the generated field.
content Only needs to be declared when the field_type is one of checkbox, radio, select or toggle. Can be a string (for "toggle" and "checkbox") or array (for "radio" and "select).
If the field_type is "select", then you can use the content to define the available options in the list (value and text of the option field).
If field_type is "radio", then you can use the content to describe the label and value of each radio input.
If field_type is "toggle", then you can use the content to declare the value of the input field.
If field_type is "checkbox", then you can use the content to declare the value of the input field.
Here is a full example for a new field in settings:
This will be the HTML output in the template:
And what you see in Settings:
All the settings are stored in storage/app/settings.json
.
Need to easily store some values in a json file? Check this package https://github.com/spatie/valuestore