Marktname öffnet Detailkarte mit Lese- und Editieransicht

This commit is contained in:
gitea_admin committed 2026-09-20 09:07:19 +02:00
1 parent f720782736
commit 1921464e27
2 files changed
+33 -14

No files matched your search

+17 -5
View File
@@ -40,11 +40,23 @@ if (!is_array($payload)) {
try {
$fields = is_array($payload['fields'] ?? null) ? $payload['fields'] : [];
$market = market_management_create_market($pdo, [
'name' => $fields['name'] ?? null,
'category_id' => $fields['category_id'] ?? null,
'website_url' => $fields['website_url'] ?? null,
]);
if (($payload['action'] ?? 'create') === 'update') {
$marketId = (int) ($payload['id'] ?? 0);
if ($marketId < 1) {
throw new InvalidArgumentException('id ist erforderlich.');
}
$market = market_management_update_market($pdo, $marketId, [
'name' => $fields['name'] ?? null,
'category_id' => $fields['category_id'] ?? null,
'website_url' => $fields['website_url'] ?? null,
]);
} else {
$market = market_management_create_market($pdo, [
'name' => $fields['name'] ?? null,
'category_id' => $fields['category_id'] ?? null,
'website_url' => $fields['website_url'] ?? null,
]);
}
echo json_encode(['ok' => true, 'market' => $market], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
} catch (Throwable $error) {
http_response_code(422);