From 8625bfc5fdbd08ea66fe87a187c80c4eaed5f59b Mon Sep 17 00:00:00 2001 From: HolgerHatGarKeineNode Date: Thu, 16 Feb 2023 21:01:53 +0100 Subject: [PATCH] deactivate bookcases --- .../Commands/OpenBooks/SyncOpenBooks.php | 59 +++++++++++-------- resources/lang/de.json | 3 +- resources/lang/en.json | 3 +- resources/lang/es.json | 3 +- resources/lang/fr.json | 3 +- resources/lang/hr.json | 3 +- resources/lang/it.json | 3 +- resources/lang/mk.json | 3 +- resources/lang/pl.json | 3 +- resources/lang/pt.json | 3 +- resources/lang/sv.json | 3 +- resources/lang/tr.json | 3 +- 12 files changed, 57 insertions(+), 35 deletions(-) diff --git a/app/Console/Commands/OpenBooks/SyncOpenBooks.php b/app/Console/Commands/OpenBooks/SyncOpenBooks.php index 345feb51..80062b80 100644 --- a/app/Console/Commands/OpenBooks/SyncOpenBooks.php +++ b/app/Console/Commands/OpenBooks/SyncOpenBooks.php @@ -28,32 +28,43 @@ class SyncOpenBooks extends Command { $response = Http::post('https://openbookcase.de/api/listarea/83.08995477111446/-200.56640625000003/-38.13455657705413/221.30859375000003'); + $ids = collect($response->json()['cases'])->pluck('id'); + foreach ($response->json()['cases'] as $case) { - BookCase::updateOrCreate( - [ - 'id' => $case['id'], - ], - [ - 'title' => $case['title'], - 'latitude' => (float)$case['lat'], - 'longitude' => (float)$case['lon'], - 'address' => $case['address'], - 'type' => $case['type'], - 'open' => $case['open'], - 'comment' => $case['comment'], - 'contact' => $case['contact'], - 'bcz' => $case['bcz'], - 'digital' => $case['digital'] ?? false, - 'icontype' => $case['icontype'], - 'deactivated' => $case['deactivated'], - 'deactreason' => $case['deactreason'], - 'entrytype' => $case['entrytype'], - 'homepage' => $case['homepage'], - 'created_by' => 1, - ] - ); + try { + BookCase::updateOrCreate( + [ + 'id' => $case['id'], + ], + [ + 'id' => $case['id'], + 'title' => $case['title'], + 'latitude' => (float) $case['lat'], + 'longitude' => (float) $case['lon'], + 'address' => $case['address'], + 'type' => $case['type'], + 'open' => $case['open'], + 'comment' => $case['comment'], + 'contact' => $case['contact'], + 'bcz' => $case['bcz'], + 'digital' => $case['digital'] ?? false, + 'icontype' => $case['icontype'], + 'deactivated' => $case['deactivated'], + 'deactreason' => $case['deactreason'], + 'entrytype' => $case['entrytype'], + 'homepage' => $case['homepage'], + 'created_by' => 1, + ] + ); + } catch (\Exception $e) { + $this->error($e->getMessage()); + } + + return Command::SUCCESS; } - return Command::SUCCESS; + BookCase::query() + ->whereNotIn('id', $ids) + ->update(['deactivated' => true]); } } diff --git a/resources/lang/de.json b/resources/lang/de.json index e1f96c5b..5fc8d6dc 100644 --- a/resources/lang/de.json +++ b/resources/lang/de.json @@ -766,5 +766,6 @@ "Article already tweeted": "Artikel bereits getwittert", "Is this a news article?": "Dieser Artikel ist ein News-Artikel", "Are your sure?": "Bist du dir sicher?", - "Nostr public key": "" + "Nostr public key": "", + "Amount": "" } \ No newline at end of file diff --git a/resources/lang/en.json b/resources/lang/en.json index 9b7fc9e9..b6978980 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -763,5 +763,6 @@ "Article already tweeted": "", "Is this a news article?": "", "Are your sure?": "", - "Nostr public key": "" + "Nostr public key": "", + "Amount": "" } \ No newline at end of file diff --git a/resources/lang/es.json b/resources/lang/es.json index 7c61e976..b54241a2 100644 --- a/resources/lang/es.json +++ b/resources/lang/es.json @@ -763,5 +763,6 @@ "Article already tweeted": "", "Is this a news article?": "", "Are your sure?": "", - "Nostr public key": "" + "Nostr public key": "", + "Amount": "" } \ No newline at end of file diff --git a/resources/lang/fr.json b/resources/lang/fr.json index deed420a..d3f28049 100644 --- a/resources/lang/fr.json +++ b/resources/lang/fr.json @@ -764,5 +764,6 @@ "Article already tweeted": "", "Is this a news article?": "", "Are your sure?": "", - "Nostr public key": "" + "Nostr public key": "", + "Amount": "" } \ No newline at end of file diff --git a/resources/lang/hr.json b/resources/lang/hr.json index fab9a2ae..2e23b515 100644 --- a/resources/lang/hr.json +++ b/resources/lang/hr.json @@ -764,5 +764,6 @@ "Article already tweeted": "", "Is this a news article?": "", "Are your sure?": "", - "Nostr public key": "" + "Nostr public key": "", + "Amount": "" } \ No newline at end of file diff --git a/resources/lang/it.json b/resources/lang/it.json index e7933dc4..7acb980c 100644 --- a/resources/lang/it.json +++ b/resources/lang/it.json @@ -764,5 +764,6 @@ "Article already tweeted": "", "Is this a news article?": "", "Are your sure?": "", - "Nostr public key": "" + "Nostr public key": "", + "Amount": "" } \ No newline at end of file diff --git a/resources/lang/mk.json b/resources/lang/mk.json index 2851ef38..e929d99b 100644 --- a/resources/lang/mk.json +++ b/resources/lang/mk.json @@ -764,5 +764,6 @@ "Article already tweeted": "", "Is this a news article?": "", "Are your sure?": "", - "Nostr public key": "" + "Nostr public key": "", + "Amount": "" } \ No newline at end of file diff --git a/resources/lang/pl.json b/resources/lang/pl.json index f8f7e478..3da98aed 100644 --- a/resources/lang/pl.json +++ b/resources/lang/pl.json @@ -764,5 +764,6 @@ "Article already tweeted": "", "Is this a news article?": "", "Are your sure?": "", - "Nostr public key": "" + "Nostr public key": "", + "Amount": "" } \ No newline at end of file diff --git a/resources/lang/pt.json b/resources/lang/pt.json index d9bb536a..8f2ae575 100644 --- a/resources/lang/pt.json +++ b/resources/lang/pt.json @@ -764,5 +764,6 @@ "Article already tweeted": "", "Is this a news article?": "", "Are your sure?": "", - "Nostr public key": "" + "Nostr public key": "", + "Amount": "" } \ No newline at end of file diff --git a/resources/lang/sv.json b/resources/lang/sv.json index ac231c50..09fbb8c1 100644 --- a/resources/lang/sv.json +++ b/resources/lang/sv.json @@ -726,5 +726,6 @@ "Article already tweeted": "", "Is this a news article?": "", "Are your sure?": "", - "Nostr public key": "" + "Nostr public key": "", + "Amount": "" } \ No newline at end of file diff --git a/resources/lang/tr.json b/resources/lang/tr.json index ec67dce6..b9bc8bac 100644 --- a/resources/lang/tr.json +++ b/resources/lang/tr.json @@ -738,5 +738,6 @@ "Article already tweeted": "", "Is this a news article?": "", "Are your sure?": "", - "Nostr public key": "" + "Nostr public key": "", + "Amount": "" } \ No newline at end of file