Skip to content

Commit

Permalink
Add geo types
Browse files Browse the repository at this point in the history
  • Loading branch information
konstmal committed May 7, 2018
1 parent df8d475 commit 0645f48
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Database/Schema/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,26 @@ public function money($column)
{
return $this->addColumn('money', $column);
}

/**
* Create a new geo point column on the table.
*
* @param string $column
* @return \Illuminate\Support\Fluent
*/
public function geoPoint($column)
{
return $this->addColumn('geoPoint', $column);
}

/**
* Create a new geo polygon column on the table.
*
* @param string $column
* @return \Illuminate\Support\Fluent
*/
public function geoPolygon($column)
{
return $this->addColumn('geoPolygon', $column);
}
}
25 changes: 25 additions & 0 deletions src/Database/Schema/Grammars/PostgresGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,29 @@ protected function typeDateRange(Fluent $column)
{
return 'daterange';
}


/**
* Create the column definition for a geo point (latitude, longitude).
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/

protected function typeGeoPoint(Fluent $column)
{
return 'geography(Point,4326)';
}

/**
* Create the column definition for a geo polygon represented by a list of points (vertices of the polygon).
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeGeoPolygon(Fluent $column)
{
return 'geography(Polygon,4326)';
}

}

0 comments on commit 0645f48

Please sign in to comment.