ichynul / configx
laravel-admin 扩展 configx
Requires
- php: >=7.0.0
- encore/laravel-admin: ~1.6
- ichynul/row-table: ^1.1.0
- laravel-admin-ext/config: ^1.0
Requires (Dev)
- phpunit/phpunit: ~6.0
- dev-master
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.9
- 1.3.8
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.14
- 1.2.13
- 1.2.12
- 1.2.11
- 1.2.10
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.0.9
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
- dev-ichynul-patch-1
This package is auto-updated.
Last update: 2024-09-18 07:53:27 UTC
README
安装
首先需要安装 laravel-admin-ext/config,请参阅 https://github.com/laravel-admin-extensions/config
然后运行
$ composer require ichynul/configx
然后运行
$ php artisan admin:import configx
在 config/admin.php
中添加标签配置
'extensions' => [ 'configx' => [ // Set to `false` if you want to disable this extension 'enable' => true, 'tabs' => [ 'base' => '基本设置', 'shop' => '店铺设置', 'uplaod' => '上传设置', 'image' => '' // if tab name is empty, get from trans : trans('admin.configx.tabs.image'); tab名称留空则从翻译中获取 ], // Whether check group permissions. //if (!Admin::user()->can('confix.tab.base')) {/*hide base tab*/ } . 'check_permission' => false, 'break_when_errors' => false // do not save anything if have errors ], ],
用法
打开 http://your-host/admin/configx/edit
演示
您可以通过点击 "+" 来配置标签
添加新的配置键
步骤 1 从 ['base']
中选择配置类型
步骤 2 从 ['normal', 'date', 'time', 'datetime', 'image', 'yes_or_no', 'number', 'rate', 'editor', 'radio_group' ,'checkbox_group', 'select']
中选择表单元素类型,等等
步骤 3 如果您选择的表单元素类型是 ['radio_group' ,'checkbox_group', 'select']
,您需要输入 [options]
仅文本
text1 text2 ...
和键值
key1 : text1 key2 : text2 ...
或从 URL 加载
options_url:/api/mydata
如果您选择的表单元素类型是 textarea
,您可以配置它 rows:3
,默认为 5。
如果您选择的表单元素类型是 table
,则需要 rows / cols
base.some_key
rows: 4
cols: 4
这将构建如下表格
/* |------------------------------------------------------------------------------------- | r_label\ c_labe | c_label1 | c_label2 | c_label3 | ⬅Col labels |------------------------------------------------------------------------------------- | r_label1 | base.some_key_1_1 | base.some_key_1_2 | base.some_key_1_3 | |------------------------------------------------------------------------------------- | r_label2 | base.some_key_2_1 | base.some_key_2_2 | base.some_key_2_3 | |------------------------------------------------------------------------------------- | r_label3 | base.some_key_3_1 | base.some_key_3_2 | base.some_key_3_3 | |------------------------------------------------------------------------------------- ↑ Row labels You can edit labels as you want. Each <td> has a key , base.some_key_[0]_[0] to base.some_key_[rows-1]_[cols-1] . (from 0 to length -1 ) So, you can chang a label <td> to input : |------------------------------------------------------------------------------------- | r_label\ c_labe | c_label1 | c_label2 | base.some_key_0_3 | ⬅ [c_label3] change to [base.some_key_0_3] |------------------------------------------------------------------------------------- , we can input here . | r_label1 | base.some_key_1_1 | base.some_key_1_2 | base.some_key_1_3 | (可以把label 换成输入元素) |------------------------------------------------------------------------------------- | r_label2 | base.some_key_2_1 | base.some_key_2_2 | base.some_key_2_3 | |------------------------------------------------------------------------------------- | trans.sometext | base.some_key_3_1 | hello world! | base.some_key_3_3 | |------------------------------------------------------------------------------------- ↑ ↑ ↑ [base.some_key_3_2] change to [hello world!] ↑ , we can not input here any more , ↑ it wiil just show label text 'hello world!' . ↑ (也可以把输入元素换成仅显示文字) ↑ get text from trans trans("admin.configx.base.some_key.sometext") 显示文字时可以从翻译获取文字,样式 `trans.sometext` 其中 sometext 为翻译的key note : if text = key or text = '' ,render as input form element , otherwise just show the text you leave. //if text is trans.sometext , get from trans : trans("admin.configx.{$tab}.{$tablekey}.{$sometext}") 总结 : 如果输入的字符串与td默认key一样或输入的字符串为空,这个位置将是一个可输入的表单元素,否则就显示原样你输入的字符串 . */ Add a lang config in `resources/lang/{zh-CN}/admin.php` ```php 'configx' => [ 'new_config_type' => '配置类型', 'new_config_key' => '配置key', 'new_config_name' => '配置名称', 'new_config_element' => '配置表单元素', 'new_config_help' => '配置help', 'new_config_options' => '配置扩展项', 'header' => '网站设置', 'desc' => '网站设置设置', 'backup' => '备份', 'element' => [ 'normal' => '默认', 'textarea' => '文本域', 'date' => '日期', 'time' => '时间', 'datetime' => '日期时间', 'password' => '密码', 'image' => '图片', 'multiple_image' => '多图', 'file' => '文件', 'multiple_file' => '多文件', 'yes_or_no' => '是或否', 'editor' => '编辑器', 'radio_group' => '单选框组', 'checkbox_group' => '多选框组', 'number' => '数字', 'rate' => '比例', 'select' => '下拉框', 'tags' => '标签', 'icon' => '图标', 'color' => '颜色', 'table' =>'表格', 'listbox' => '左右多选框', 'multiple_select' => '下拉多选', 'map' => '地图' ], ], 'yes' => '是', 'no' => '否'
如果您需要添加新的配置标签,请在 config/admin.php
中修改它。
在面板中添加配置后,使用 config($key)
来获取您配置的值。
许可
在 MIT 许可证 (MIT) 下授权。