sadasd
All checks were successful
Deploy / deploy (push) Successful in 56s

This commit is contained in:
2026-08-19 20:04:01 +02:00
parent c2eaa5c186
commit c567d19deb
13 changed files with 177 additions and 38 deletions

View File

@@ -368,6 +368,35 @@ final class ListingCatalog
}
}
public function confirmCategory(string $sourceSlug): void
{
$this->ensureSchema();
$sourceSlug = trim($sourceSlug);
if ($sourceSlug === '') {
throw new \RuntimeException('Kategorie nicht gefunden.');
}
$lookup = $this->pdo->prepare('SELECT id, sort_order FROM listing_categories WHERE slug = :slug LIMIT 1');
$lookup->execute(['slug' => $sourceSlug]);
$source = $lookup->fetch(\PDO::FETCH_ASSOC);
if (!$source) {
throw new \RuntimeException('Kategorie nicht gefunden.');
}
if ((int)($source['sort_order'] ?? 0) < 900) {
return;
}
$maxStmt = $this->pdo->query('SELECT COALESCE(MAX(sort_order), 0) FROM listing_categories WHERE sort_order < 900');
$maxSortOrder = (int)($maxStmt?->fetchColumn() ?: 0);
$newSortOrder = max(1, $maxSortOrder + 1);
$update = $this->pdo->prepare('UPDATE listing_categories SET sort_order = :sortOrder, updated_at = NOW() WHERE id = :id');
$update->execute([
'sortOrder' => $newSortOrder,
'id' => (int)$source['id'],
]);
}
public function resolveExistingCategorySlug(string $input): ?string
{
$this->ensureSchema();