for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace LaravelSpatial;
use Doctrine\DBAL\Types\Type;
class MysqlConnection extends \Illuminate\Database\MySqlConnection
{
public function __construct($pdo, $database = '', $tablePrefix = '', array $config = [])
parent::__construct($pdo, $database, $tablePrefix, $config);
if (class_exists(Type::class)) {
// Prevent geometry type fields from throwing a 'type not found' error when changing them
$geometries = [
'geometry',
'point',
'linestring',
'polygon',
'multipoint',
'multilinestring',
'multipolygon',
'geomcollection',
'geometrycollection',
];
$dbPlatform = $this->getDoctrineSchemaManager()->getDatabasePlatform();
foreach ($geometries as $type) {
$dbPlatform->registerDoctrineTypeMapping($type, 'string');
}
public function getSchemaBuilder()
if (is_null($this->schemaGrammar)) {
$this->useDefaultSchemaGrammar();
return new Schema\Builder($this);
/**
* Get the default schema grammar instance.
*
* @return \Illuminate\Database\Grammar
*/
protected function getDefaultSchemaGrammar()
return $this->withTablePrefix(new Schema\Grammars\MySqlGrammar());