catchSearch() ->order(['sort', 'id']) ->paginate(); } public function searchNameAttr($query, $value, $data) { return $query->whereLike('name', $value); } public function searchCodeAttr($query, $value, $data) { return $query->whereLike('code', $value); } /** * 根据 code 获取字典类型 id */ public static function getTypeIdByCode($code) { if (\think\facade\Cache::has("dict_type_{$code}")) { return \think\facade\Cache::get("dict_type_{$code}"); } return SysDictType::where('code', $code)->cache("dict_type_{$code}", 60)->value('id'); } }