Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #138 from forsalio/master
Browse files Browse the repository at this point in the history
Fix connecting to database when package is registered
  • Loading branch information
mstaack authored Sep 1, 2020
2 parents a3bb482 + 87f252f commit 9e3fbcb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/Connectors/ConnectionFactory.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace MStaack\LaravelPostgis\Connectors;

use Illuminate\Database\Connection;
use PDO;
use MStaack\LaravelPostgis\PostgisConnection;

Expand All @@ -15,8 +16,8 @@ class ConnectionFactory extends \Bosnadev\Database\Connectors\ConnectionFactory
*/
protected function createConnection($driver, $connection, $database, $prefix = '', array $config = [])
{
if ($this->container->bound($key = "db.connection.{$driver}")) {
return $this->container->make($key, [$connection, $database, $prefix, $config]);
if ($resolver = Connection::getResolver($driver)) {
return $resolver($connection, $database, $prefix, $config);
}

if ($driver === 'pgsql') {
Expand Down
9 changes: 0 additions & 9 deletions src/PostgisConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@

class PostgisConnection extends PostgresConnection
{
public function __construct($pdo, $database = '', $tablePrefix = '', array $config = [])
{
parent::__construct($pdo, $database, $tablePrefix, $config);

// Prevent geography type fields from throwing a 'type not found' error.
$this->getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('geography', 'string');
$this->getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('geometry', 'string');
}

/**
* Get the default schema grammar instance.
*
Expand Down

0 comments on commit 9e3fbcb

Please sign in to comment.