| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace app\admin\model;
- use app\BaseModel;
- class Config extends BaseModel
- {
- protected $json = ['val'];
- protected $jsonAssoc = true;
-
- public static function getSelect($select = true) {
- $data = [
- 'kefu_chat_type' => [
- 1 => '顺序分配'
- ],
- 'user_vip_level' => [
- 1 => 1,
- 2 => 2,
- 3 => 3,
- 4 => 4,
- 5 => 5,
- 6 => 6,
- 7 => 7,
- 8 => 8,
- 9 => 9,
- ]
- ];
- if ($select) {
- foreach ($data as &$item) {
- $item = getSelectData($item);
- }
- }
- return $data;
- }
- //字段val如果是json格式,转换为数组
- public function getValAttribute($value)
- {
- return $value ? json_decode($value, true) : '';
- }
- //获取配置数据
- public static function getConfigData($fields, $flag = 1)
- {
- if (!empty($fields)) {
- $list = Config::whereIn('field',$fields)->select();
- } else {
- $list = Config::where('flag',$flag)->whereIn('field',$fields)->select();
- }
- $data = [];
- foreach ($list as $item) {
- $data[$item['field']] = $item['val'];
- }
- return $data;
- }
- }
|