@@ -48,8 +48,8 @@ public function register(SiteRequest $request): JsonResponse
4848 return $ this ->error ($ e ->getMessage (), 500 );
4949 }
5050
51- // If successful save site
52- $ site = new Site ();
51+ // If successful create or update site
52+ $ site = Site:: where ( ' url ' , $ url )-> where ( ' key ' , $ key )-> first () ?? new Site ();
5353
5454 $ site ->key = $ key ;
5555 $ site ->url = $ url ;
@@ -77,14 +77,14 @@ public function check(SiteRequest $request): JsonResponse
7777
7878 try {
7979 /** @var Site $site */
80- $ site = Site::where ('url ' , $ url )->where ('key ' , $ key )->findOrFail ();
80+ $ site = Site::where ('url ' , $ url )->where ('key ' , $ key )->firstOrFail ();
8181 } catch (\Exception $ e ) {
8282 return $ this ->error ("Not found " , 404 );
8383 }
8484
8585 // Do a health check
8686 try {
87- $ site ->getConnection () ->checkHealth ();
87+ $ site ->connection ->checkHealth ();
8888 } catch (ServerException |ClientException $ e ) {
8989 return $ this ->error ($ e ->getMessage (), 400 );
9090 } catch (\Exception $ e ) {
@@ -105,7 +105,7 @@ public function delete(SiteRequest $request): JsonResponse
105105 $ key = $ request ->string ('key ' );
106106
107107 try {
108- $ site = Site::where ('url ' , $ url )->where ('key ' , $ key )->findOrFail ();
108+ $ site = Site::where ('url ' , $ url )->where ('key ' , $ key )->firstOrFail ();
109109 } catch (\Exception $ e ) {
110110 return $ this ->error ("Not found " , 404 );
111111 }
0 commit comments