From 132d15f36885ba06f0ea2d1715f2e7e148f37df1 Mon Sep 17 00:00:00 2001 From: Philipp Lang Date: Tue, 15 Aug 2023 13:24:07 +0200 Subject: [PATCH] Add check for geolocation update --- src/Geolocatable.php | 2 ++ src/HasGeolocation.php | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Geolocatable.php b/src/Geolocatable.php index 43ce4ac..be57ebf 100644 --- a/src/Geolocatable.php +++ b/src/Geolocatable.php @@ -9,4 +9,6 @@ interface Geolocatable public function getAddressForGeolocation(): ?Address; public function destroyCoordinate(): void; + + public function needsGeolocationUpdate(): bool; } diff --git a/src/HasGeolocation.php b/src/HasGeolocation.php index b7a50b5..735ceec 100644 --- a/src/HasGeolocation.php +++ b/src/HasGeolocation.php @@ -12,7 +12,10 @@ trait HasGeolocation if (!static::$geolocationEnabled) { return; } - dispatch(new FillCoordsJob($model)); + + if ($model->needsGeolocationUpdate()) { + dispatch(new FillCoordsJob($model)); + } }); }