Skip to content

Commit a10ae58

Browse files
committed
Remove duplicate site rows on a successful registration
1 parent 66006da commit a10ae58

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

app/Http/Controllers/Api/V1/SiteController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ public function register(SiteRequest $request): JsonResponse
4848
return $this->error($e->getMessage(), 500);
4949
}
5050

51-
// If successful create or update site
52-
$site = Site::where('url', $url)->where('key', $key)->first() ?? new Site();
51+
// Remove older duplicates of the site if registered
52+
Site::query()->where('url', $url)->delete();
5353

54+
// Create new row
55+
$site = new Site();
5456
$site->key = $key;
5557
$site->url = $url;
5658
$site->last_seen = Carbon::now();

0 commit comments

Comments
 (0)