Setting Module
Adding settings for you module is very easy. All you need to do is add a settings.php
configuration file in YourModule/config/settings.php
, and return an array of settings you want.
You will also have to load that setting file in your service provider, like so:
$this->publishConfig('moduleName', 'permissions');
The first argument is the module name and the second the file name without extension.
The settings are registered in the following manner:
return [
'posts-per-page' => [
'description' => trans('blog::settings.posts-per-page'),
'view' => 'text',
'translatable' => true,
'default' => 15,
],
'this-is-a-checkbox' => [
'description' => 'This is a checkbox',
'view' => 'checkbox',
'translatable' => true,
],
'this-is-a-textarea' => [
'description' => 'This is a textarea',
'view' => 'textarea',
'translatable' => true,
],
];
The array key being the setting name, holding an array of information.
The information array needs the following:
description
key: this will be the label / placeholder,view
key: which points to the view holding the field,translatable
key: defines if the setting is translatable (set in multiple languages)default
key (optional): defines a default value for your setting if none is present and none is set in the third argument of Setting::get()
.Not every setting has to be translatable, plain settings are settings that aren't translated.
'plain-non-translated-setting' => [
'description' => 'A plain setting',
'view' => 'text',
'default' => 'your default value',
],