diff --git a/composer.json b/composer.json index 1d536f22..c38114dc 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { - "name": "reliese/laravel", - "description": "Reliese Components for Laravel Framework code generation.", + "name": "jrodella/laravel_model_generator", + "description": "Reliese Components for Laravel Framework code generation. (This is a fork from: reliese/laravel)", "keywords": ["reliese", "laravel"], "homepage": "http://cristianllanos.com", "support": { diff --git a/src/Meta/Postgres/Schema.php b/src/Meta/Postgres/Schema.php index edfb0e27..9e9a49b1 100644 --- a/src/Meta/Postgres/Schema.php +++ b/src/Meta/Postgres/Schema.php @@ -283,7 +283,8 @@ protected function wrap($table) */ public static function schemas(Connection $connection) { - $schemas = $connection->getDoctrineSchemaManager()->listDatabases(); + $schemas = $connection->select('SELECT schema_name FROM information_schema.schemata'); + $schemas = array_column($schemas, 'schema_name'); return array_diff($schemas, [ 'postgres', diff --git a/src/Meta/SchemaManager.php b/src/Meta/SchemaManager.php index ba98da05..a8c439cd 100644 --- a/src/Meta/SchemaManager.php +++ b/src/Meta/SchemaManager.php @@ -35,6 +35,11 @@ class SchemaManager implements IteratorAggregate */ private $connection; + /** + * @var string + */ + private $type; + /** * @var \Reliese\Meta\Schema[] */ @@ -107,7 +112,16 @@ protected function getMapper() */ protected function type() { - return get_class($this->connection); + return empty($this->type) ? get_class($this->connection) : $this->type; + } + + /** + * @param string $type + */ + protected function setType($type) + { + $this->type = $type; + return $this; } /** @@ -115,7 +129,18 @@ protected function type() */ protected function hasMapping() { - return array_key_exists($this->type(), static::$lookup); + $hasMapping = array_key_exists($this->type(), static::$lookup); + if ($hasMapping) { + return $hasMapping; + } + foreach (static::$lookup as $class => $schema) { + if (is_subclass_of($this->type(), $class)) { + $hasMapping = true; + $this->setType($class); + break; + } + } + return $hasMapping; } /**