From c527d35e842cf976318e2dfd60cd98e35c048b91 Mon Sep 17 00:00:00 2001
From: h-ishak <ishaker2542@gmail.com>
Date: Mon, 14 Feb 2022 13:25:06 +0100
Subject: [PATCH] fixing an error in the SpatialTrait  where the self value
 wasnt 0 from the SGBD

---
 src/Eloquent/SpatialTrait.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Eloquent/SpatialTrait.php b/src/Eloquent/SpatialTrait.php
index 5cc3f4b1..e2728cbd 100755
--- a/src/Eloquent/SpatialTrait.php
+++ b/src/Eloquent/SpatialTrait.php
@@ -149,7 +149,7 @@ public function scopeDistanceExcludingSelf($query, $geometryColumn, $geometry, $
 
         $query = $this->scopeDistance($query, $geometryColumn, $geometry, $distance);
 
-        $query->whereRaw("st_distance(`$geometryColumn`, ST_GeomFromText(?, ?, 'axis-order=long-lat')) != 0", [
+        $query->whereRaw("st_distance(`$geometryColumn`, ST_GeomFromText(?, ?, 'axis-order=long-lat')) > 0.1", [
             $geometry->toWkt(),
             $geometry->getSrid(),
         ]);
@@ -192,7 +192,7 @@ public function scopeDistanceSphereExcludingSelf($query, $geometryColumn, $geome
 
         $query = $this->scopeDistanceSphere($query, $geometryColumn, $geometry, $distance);
 
-        $query->whereRaw("st_distance_sphere($geometryColumn, ST_GeomFromText(?, ?, 'axis-order=long-lat')) != 0", [
+        $query->whereRaw("st_distance_sphere($geometryColumn, ST_GeomFromText(?, ?, 'axis-order=long-lat')) > 0.1", [
             $geometry->toWkt(),
             $geometry->getSrid(),
         ]);