This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user