[ 1 => Lang::get('顺序分配') ], '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; } //获取客服接线数量的上限配置 public static function getKefuChatMax() { //先从缓存中读取config表获取客服接线数量的上限配置 $kefu_chat_max = cache('config_kefu_chat_max'); if ($kefu_chat_max) { return $kefu_chat_max; } $config = Config::whereIn('field',['kefu_chat_max'])->column('val', 'field'); cache('config_kefu_chat_max', $config['kefu_chat_max'] ?? 0); return $config['kefu_chat_max'] ?? 0; } }