Skip to content

Commit

Permalink
[6.x] Improve formatPostGisType method readability (#30593)
Browse files Browse the repository at this point in the history
* Improve readability

* Improve geography type readability
  • Loading branch information
antonkomarev authored and taylorotwell committed Nov 15, 2019
1 parent 274020b commit b12f4be
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -888,11 +888,15 @@ protected function typeMultiPolygonZ(Fluent $column)
*/
private function formatPostGisType(string $type, Fluent $column)
{
if ($column->isGeometry !== null) {
return "geometry($type".($column->projection === null ? '' : ", $column->projection").')';
if ($column->isGeometry === null) {
return sprintf('geography(%s, %s)', $type, $column->projection ?? '4326');
}

return "geography($type, ".($column->projection ?? '4326').')';
if ($column->projection !== null) {
return sprintf('geometry(%s, %s)', $type, $column->projection);
}

return "geometry({$type})";
}

/**
Expand Down

0 comments on commit b12f4be

Please sign in to comment.