Skip to content

Commit

Permalink
Add support for defining a Spatial reference system for a Point column.
Browse files Browse the repository at this point in the history
  • Loading branch information
jochem committed May 25, 2018
1 parent a580df5 commit 22df6bd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/Illuminate/Database/Schema/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -1061,12 +1061,13 @@ public function geometry($column)
/**
* Create a new point column on the table.
*
* @param string $column
* @param string $column
* @param null|int $srid
* @return \Illuminate\Support\Fluent
*/
public function point($column)
public function point($column, $srid = null)
{
return $this->addColumn('point', $column);
return $this->addColumn('point', $column, compact('srid'));
}

/**
Expand Down
16 changes: 15 additions & 1 deletion src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MySqlGrammar extends Grammar
*/
protected $modifiers = [
'Unsigned', 'VirtualAs', 'StoredAs', 'Charset', 'Collate', 'Nullable',
'Default', 'Increment', 'Comment', 'After', 'First',
'Default', 'Increment', 'Comment', 'After', 'First', 'Srid',
];

/**
Expand Down Expand Up @@ -966,6 +966,20 @@ protected function modifyComment(Blueprint $blueprint, Fluent $column)
}
}

/**
* Get the SQL for a SRID column modifier.
*
* @param \Illuminate\Database\Schema\Blueprint $blueprint
* @param \Illuminate\Support\Fluent $column
* @return string|null
*/
protected function modifySrid(Blueprint $blueprint, Fluent $column)
{
if (! is_null($column->srid) && is_int($column->srid) && $column->srid > 0) {
return ' srid '. $column->srid;
}
}

/**
* Wrap a single string in keyword identifiers.
*
Expand Down

0 comments on commit 22df6bd

Please sign in to comment.