Adding Settings
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:
'My New Section' => [ // Text for the header
// Your fields here
]
Each array inside represents a field:
[
'name' => 'my_setting',
'label' => 'My Setting',
'field_type' => 'text',
'icon' => 'ni ni-email-83',
'info_text' => 'This is my new setting.',
'required' => true,
'content' => null
],
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.
// For field_type => 'select' 'content' => [ 'value_1' => 'First option', 'value_2' => 'Second option' ], // For field_type => 'radio' 'content' => [ [ 'label' => 'First option', 'value' => 1 ], [ 'label' => 'Second option', 'value' => 2 ], ], // For field_type => 'toggle' or 'checkbox' 'content' => 'active',
Here is a full example for a new field in settings:
// config/hotcoffee/settings.php
'fields' => [
// Some section
'My New Section' => [
// My custom setting
[
'name' => 'my_setting',
'label' => 'My Setting',
'field_type' => 'select',
'icon' => 'ni ni-email-83',
'info_text' => 'This is my new setting.',
'required' => true,
'content' => [
'value_1' => 'This is value 1',
'value_2' => 'This is value 2'
]
] // End custom setting
], // end "some section"
...
This will be the HTML output in the template:
<div class="col-md-12 form-header text-uppercase">
Section name / header text
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group focused">
<label class="form-control-label" for="input-my_setting">
My Setting
<span class="text-danger">*</span>
<small class="text-primary">setting('my_setting')</small>
</label>
<select id="input-my_setting" class="form-control form-control-alternative no-border-radius" name="my_setting">
<option value="value_1">This is value 1</option>
<option value="value_2">This is value 2</option>
</select>
</div>
</div>
<div class="col-lg-12 info-div">
This is my new setting.
</div>
</div>
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
Last updated