Skip to content

Commit 1879c79

Browse files
committed
updates
1 parent 54f370a commit 1879c79

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/Postgis.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@ trait Postgis
1515
* @param Point $location
1616
* @return Builder
1717
*/
18-
public function scopeWithDistance(Builder $query, Point $location = null)
18+
public function scopeWithDistance(Builder $query, $location)
1919
{
2020
$classQuery = $query->getQuery();
2121

2222
if ($classQuery && !$classQuery->columns) {
2323
$query->select([$classQuery->from . '.*']);
2424
}
2525

26-
2726
if ($location) {
2827
$longitude = $location->getLng();
2928
$latitude = $location->getLat();
@@ -58,18 +57,18 @@ public function scopeWithGeofence(Builder $query, Point $location = null, $inner
5857
* @param float $units
5958
* @return Builder
6059
*/
61-
public function scopeWhereDistance(Builder $query, Point $location, $operator, $units)
60+
public function scopeWhereDistance(Builder $query, $location, $operator, $units)
6261
{
6362
$classQuery = $query->getQuery();
6463

6564
if ($classQuery && !$classQuery->columns) {
6665
$query->select([$classQuery->from . '.*']);
6766
}
6867

69-
$longitude = $location ? $location->getLng() : null;
70-
$latitude = $location ? $location->getLat() : null;
68+
if ($location) {
69+
$longitude = $location->getLng();
70+
$latitude = $location->getLat();
7171

72-
if ($longitude && $latitude) {
7372
$q = "ST_Distance({$this->getLocationColumn()},ST_Point({$longitude},{$latitude}))";
7473
} else {
7574
$q = "0";
@@ -101,5 +100,4 @@ private function getDivisionFactor()
101100

102101
return $division;
103102
}
104-
105103
}

0 commit comments

Comments
 (0)