@@ -15,8 +15,6 @@ public function withDistance(
1515 Geometry | string $ geometryOrColumn ,
1616 string $ alias = 'distance '
1717 ): self {
18- $ geometryOrColumn = $ this ->toExpression ($ geometryOrColumn );
19-
2018 if (! $ this ->getQuery ()->columns ) {
2119 $ this ->select ('* ' );
2220 }
@@ -25,7 +23,7 @@ public function withDistance(
2523 sprintf (
2624 'ST_DISTANCE(%s, %s) AS %s ' ,
2725 "` {$ column }` " ,
28- $ geometryOrColumn ,
26+ $ this -> toExpression ( $ geometryOrColumn) ,
2927 $ alias ,
3028 )
3129 );
@@ -37,13 +35,11 @@ public function whereDistance(
3735 string $ operator ,
3836 int | float $ value
3937 ): self {
40- $ geometryOrColumn = $ this ->toExpression ($ geometryOrColumn );
41-
4238 return $ this ->whereRaw (
4339 sprintf (
4440 'ST_DISTANCE(%s, %s) %s %s ' ,
4541 "` {$ column }` " ,
46- $ geometryOrColumn ,
42+ $ this -> toExpression ( $ geometryOrColumn) ,
4743 $ operator ,
4844 $ value ,
4945 )
@@ -55,13 +51,11 @@ public function orderByDistance(
5551 Geometry | string $ geometryOrColumn ,
5652 string $ direction = 'asc '
5753 ): self {
58- $ geometryOrColumn = $ this ->toExpression ($ geometryOrColumn );
59-
6054 return $ this ->orderByRaw (
6155 sprintf (
6256 'ST_DISTANCE(%s, %s) %s ' ,
6357 "` {$ column }` " ,
64- $ geometryOrColumn ,
58+ $ this -> toExpression ( $ geometryOrColumn) ,
6559 $ direction ,
6660 )
6761 );
@@ -72,8 +66,6 @@ public function withDistanceSphere(
7266 Geometry | string $ geometryOrColumn ,
7367 string $ alias = 'distance '
7468 ): self {
75- $ geometryOrColumn = $ this ->toExpression ($ geometryOrColumn );
76-
7769 if (! $ this ->getQuery ()->columns ) {
7870 $ this ->select ('* ' );
7971 }
@@ -82,7 +74,7 @@ public function withDistanceSphere(
8274 sprintf (
8375 'ST_DISTANCE_SPHERE(%s, %s) AS %s ' ,
8476 "` {$ column }` " ,
85- $ geometryOrColumn ,
77+ $ this -> toExpression ( $ geometryOrColumn) ,
8678 $ alias ,
8779 )
8880 );
@@ -94,13 +86,11 @@ public function whereDistanceSphere(
9486 string $ operator ,
9587 int | float $ value
9688 ): self {
97- $ geometryOrColumn = $ this ->toExpression ($ geometryOrColumn );
98-
9989 return $ this ->whereRaw (
10090 sprintf (
10191 'ST_DISTANCE_SPHERE(%s, %s) %s %s ' ,
10292 "` {$ column }` " ,
103- $ geometryOrColumn ,
93+ $ this -> toExpression ( $ geometryOrColumn) ,
10494 $ operator ,
10595 $ value
10696 )
@@ -112,118 +102,100 @@ public function orderByDistanceSphere(
112102 Geometry | string $ geometryOrColumn ,
113103 string $ direction = 'asc '
114104 ): self {
115- $ geometryOrColumn = $ this ->toExpression ($ geometryOrColumn );
116-
117105 return $ this ->orderByRaw (
118106 sprintf (
119107 'ST_DISTANCE_SPHERE(%s, %s) %s ' ,
120108 "` {$ column }` " ,
121- $ geometryOrColumn ,
109+ $ this -> toExpression ( $ geometryOrColumn) ,
122110 $ direction
123111 )
124112 );
125113 }
126114
127115 public function whereWithin (string $ column , Geometry | string $ geometryOrColumn ): self
128116 {
129- $ geometryOrColumn = $ this ->toExpression ($ geometryOrColumn );
130-
131117 return $ this ->whereRaw (
132118 sprintf (
133119 'ST_WITHIN(%s, %s) ' ,
134120 "` {$ column }` " ,
135- $ geometryOrColumn ,
121+ $ this -> toExpression ( $ geometryOrColumn) ,
136122 )
137123 );
138124 }
139125
140126 public function whereContains (string $ column , Geometry | string $ geometryOrColumn ): self
141127 {
142- $ geometryOrColumn = $ this ->toExpression ($ geometryOrColumn );
143-
144128 return $ this ->whereRaw (
145129 sprintf (
146130 'ST_CONTAINS(%s, %s) ' ,
147131 "` {$ column }` " ,
148- $ geometryOrColumn ,
132+ $ this -> toExpression ( $ geometryOrColumn) ,
149133 )
150134 );
151135 }
152136
153137 public function whereTouches (string $ column , Geometry | string $ geometryOrColumn ): self
154138 {
155- $ geometryOrColumn = $ this ->toExpression ($ geometryOrColumn );
156-
157139 return $ this ->whereRaw (
158140 sprintf (
159141 'ST_TOUCHES(%s, %s) ' ,
160142 "` {$ column }` " ,
161- $ geometryOrColumn ,
143+ $ this -> toExpression ( $ geometryOrColumn) ,
162144 )
163145 );
164146 }
165147
166148 public function whereIntersects (string $ column , Geometry | string $ geometryOrColumn ): self
167149 {
168- $ geometryOrColumn = $ this ->toExpression ($ geometryOrColumn );
169-
170150 return $ this ->whereRaw (
171151 sprintf (
172152 'ST_INTERSECTS(%s, %s) ' ,
173153 "` {$ column }` " ,
174- $ geometryOrColumn ,
154+ $ this -> toExpression ( $ geometryOrColumn) ,
175155 )
176156 );
177157 }
178158
179159 public function whereCrosses (string $ column , Geometry | string $ geometryOrColumn ): self
180160 {
181- $ geometryOrColumn = $ this ->toExpression ($ geometryOrColumn );
182-
183161 return $ this ->whereRaw (
184162 sprintf (
185163 'ST_CROSSES(%s, %s) ' ,
186164 "` {$ column }` " ,
187- $ geometryOrColumn ,
165+ $ this -> toExpression ( $ geometryOrColumn) ,
188166 )
189167 );
190168 }
191169
192170 public function whereDisjoint (string $ column , Geometry | string $ geometryOrColumn ): self
193171 {
194- $ geometryOrColumn = $ this ->toExpression ($ geometryOrColumn );
195-
196172 return $ this ->whereRaw (
197173 sprintf (
198174 'ST_DISJOINT(%s, %s) ' ,
199175 "` {$ column }` " ,
200- $ geometryOrColumn ,
176+ $ this -> toExpression ( $ geometryOrColumn) ,
201177 )
202178 );
203179 }
204180
205181 public function whereOverlaps (string $ column , Geometry | string $ geometryOrColumn ): self
206182 {
207- $ geometryOrColumn = $ this ->toExpression ($ geometryOrColumn );
208-
209183 return $ this ->whereRaw (
210184 sprintf (
211185 'ST_OVERLAPS(%s, %s) ' ,
212186 "` {$ column }` " ,
213- $ geometryOrColumn ,
187+ $ this -> toExpression ( $ geometryOrColumn) ,
214188 )
215189 );
216190 }
217191
218192 public function whereEquals (string $ column , Geometry | string $ geometryOrColumn ): self
219193 {
220- $ geometryOrColumn = $ this ->toExpression ($ geometryOrColumn );
221-
222194 return $ this ->whereRaw (
223195 sprintf (
224196 'ST_EQUALS(%s, %s) ' ,
225197 "` {$ column }` " ,
226- $ geometryOrColumn ,
198+ $ this -> toExpression ( $ geometryOrColumn) ,
227199 )
228200 );
229201 }
0 commit comments