Skip to content

Commit 0645f48

Browse files
committed
Add geo types
1 parent df8d475 commit 0645f48

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

src/Database/Schema/Blueprint.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,26 @@ public function money($column)
195195
{
196196
return $this->addColumn('money', $column);
197197
}
198+
199+
/**
200+
* Create a new geo point column on the table.
201+
*
202+
* @param string $column
203+
* @return \Illuminate\Support\Fluent
204+
*/
205+
public function geoPoint($column)
206+
{
207+
return $this->addColumn('geoPoint', $column);
208+
}
209+
210+
/**
211+
* Create a new geo polygon column on the table.
212+
*
213+
* @param string $column
214+
* @return \Illuminate\Support\Fluent
215+
*/
216+
public function geoPolygon($column)
217+
{
218+
return $this->addColumn('geoPolygon', $column);
219+
}
198220
}

src/Database/Schema/Grammars/PostgresGrammar.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,29 @@ protected function typeDateRange(Fluent $column)
218218
{
219219
return 'daterange';
220220
}
221+
222+
223+
/**
224+
* Create the column definition for a geo point (latitude, longitude).
225+
*
226+
* @param \Illuminate\Support\Fluent $column
227+
* @return string
228+
*/
229+
230+
protected function typeGeoPoint(Fluent $column)
231+
{
232+
return 'geography(Point,4326)';
233+
}
234+
235+
/**
236+
* Create the column definition for a geo polygon represented by a list of points (vertices of the polygon).
237+
*
238+
* @param \Illuminate\Support\Fluent $column
239+
* @return string
240+
*/
241+
protected function typeGeoPolygon(Fluent $column)
242+
{
243+
return 'geography(Polygon,4326)';
244+
}
245+
221246
}

0 commit comments

Comments
 (0)