mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
deactivate bookcases
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user