src/ApiTrait.php
private function _doFilters(Request $request, Builder $builder, $columns = [])
	{
		$filters = $this->_getFilters($request);
		$operators = [
			'in' => 'in', 'nin' => 'not in', 'is' => 'is',
			'min' => '>=', 'gte' => '>=', 'max' => '<=', 'lte' => '<=', 'btw' => 'between', 'nbtw' => 'not between', 'gt' => '>', 'lt' => '<',
			'neq' => '<>', 'ne' => '<>', 'eq' => '=', 'equal' => '=',
			'lk' => 'like', 'like' => 'like', 'lkb' => 'like binary',
			'nlk' => 'not like', 'nlkb' => 'not like binary',
			'rlk' => 'rlike', 'ilk' => 'ilike',
			'and' => '&', 'or' => '|', 'xor' => '^', 'left_shift' => '<<', 'right_shift' => '>>', 'bitwise_not' => '~', 'bitwise_not_any' => '~*', 'not_bitwise_not' => '!~', 'not_bitwise_not_any' => '!~*',
			'regexp' => 'regexp', 'not_regexp' => 'not regexp', 'similar_to' => 'similar to', 'not_similar_to' => 'not similar to',
		];
		foreach ($filters as $key => $filter)
		{
			$key = !empty($columns[$key]) ? $columns[$key] : $key;
			foreach ($filter as $method => $value)
			{
				$operator = $operators[$method];
				if (empty($value) && $value !== '0') continue; //''不做匹配
				else if (in_array($operator, ['like', 'like binary', 'not like', 'not like binary']))
					$value = trim($value, '%') != $value ? $value : '%'.$value.'%'; //如果开头结尾有 % 则以用户的为准

				if ($operator == 'in')
					$builder->whereIn($key, $value);
				else if ($operator == 'not in')
					$builder->whereNotIn($key, $value);
				else
					$builder->where($key, $operator ?: '=' , $value);
			}
		}
		return $filters;
	}
private function _doFilters(Request $request, Builder $builder, $columns = [])
	{
		$filters = $this->_getFilters($request);
		$operators = [
			'in' => 'in', 'nin' => 'not in', 'is' => 'is',
			'min' => '>=', 'gte' => '>=', 'max' => '<=', 'lte' => '<=', 'btw' => 'between', 'nbtw' => 'not between', 'gt' => '>', 'lt' => '<',
			'neq' => '<>', 'ne' => '<>', 'eq' => '=', 'equal' => '=',
			'lk' => 'like', 'like' => 'like', 'lkb' => 'like binary',
			'nlk' => 'not like', 'nlkb' => 'not like binary',
			'rlk' => 'rlike', 'ilk' => 'ilike',
			'and' => '&', 'or' => '|', 'xor' => '^', 'left_shift' => '<<', 'right_shift' => '>>', 'bitwise_not' => '~', 'bitwise_not_any' => '~*', 'not_bitwise_not' => '!~', 'not_bitwise_not_any' => '!~*',
			'regexp' => 'regexp', 'not_regexp' => 'not regexp', 'similar_to' => 'similar to', 'not_similar_to' => 'not similar to',
		];
		foreach ($filters as $key => $filter)
		{
			$key = !empty($columns[$key]) ? $columns[$key] : $key;
			foreach ($filter as $method => $value)
			{
				$operator = $operators[$method];
				if (empty($value) && $value !== '0') continue; //''不做匹配
				else if (in_array($operator, ['like', 'like binary', 'not like', 'not like binary']))
					$value = trim($value, '%') != $value ? $value : '%'.$value.'%'; //如果开头结尾有 % 则以用户的为准

				if ($operator == 'in')
					$builder->whereIn($key, $value);
				else if ($operator == 'not in')
					$builder->whereNotIn($key, $value);
				else
					$builder->where($key, $operator ?: '=' , $value);
			}
		}
		return $filters;
	}
给Builder绑定where条件
注意：参数的值为空字符串，则会忽略该条件

@param  Request $request
@param  Builder $builder
@return array           返回筛选(搜索)的参数