orderBy($target); } if ($order === self::ORDER_DESC) { $query->orderByDesc($target); } } protected static function limit(Builder $query, array $condition, int $default = self::MAX_LIMIT) { $limit = data_get($condition, self::CONDITION_LIMIT, $default) ?? $default; $limit = min($limit, self::MAX_LIMIT); $query->limit($limit); } protected static function where(Builder $query, array $condition, string $conditionKey, string|null $columnName = null): bool { $ret = data_get($condition, $conditionKey); if ($ret !== null) { $query->where($columnName ?? $conditionKey, $ret); return true; } else { return false; } } protected static function whereIn(Builder $query, array $condition, string $conditionKey, string|null $columnName = null): bool { $ret = data_get($condition, $conditionKey); if ($ret !== null && is_array($ret)) { $query->whereIn($columnName ?? $conditionKey, $ret); return true; } else { return false; } } }