where('rule', 'LIKE', '%' . $where['rule_name'] . '%'); $model = $model->order('id desc'); $list = $model->page((int)$where['page'], (int)$where['limit']) ->select() ->each(function ($item) { if ($item['rule_value']) { $specs = json_decode($item['rule_value'], true); foreach ($specs as $key => $value) { $attr_name[] = $value['value']; $attr_value[] = implode(',', $value['detail']); } $item['attr_name'] = implode(',', $attr_name); $item['attr_value'] = $attr_value; } }); $data = count($list) ? $list->toArray() : []; $count = $model->count(); return compact('count', 'data'); } /** * 详情 * @param $id * @return array */ public static function sysInfo($id) { $info = self::get($id); $info['rule_value'] = json_decode($info['rule_value'], true); return $info; } }