ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
``` /** * 搜索输入的字段 * @param $list * @param $whereField * @param $input * @return mixed */ public static function orWhereField($list, $whereField, $input) { if (isset($input['search'])) { foreach ($whereField as $where) { if(is_array( $input[$where[2]] )) { $list = $list->orWhereIn($where[0], $where[1], $input[$where[2]]); } else { if($where[1] == 'like') { $list = $list->orWhere($where[0], $where[1], '%'.$input[$where[2]].'%'); } if($where[1] == '=') { $list = $list->orWhere($where[0], $where[1], $input[$where[2]]); } } } } return $list; } /** * 动态获取用户查询的字段排序 * @param Request $request * @return mixed */ public static function sortField($list, $sortField, $input) { foreach ($sortField as $field) { if (isset($input[$field])) { $list = $list->orderBy($field, $input[$field]); } } return $list; } ```