Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
3 changes: 2 additions & 1 deletion src/Meta/Postgres/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
29 changes: 27 additions & 2 deletions src/Meta/SchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class SchemaManager implements IteratorAggregate
*/
private $connection;

/**
* @var string
*/
private $type;

/**
* @var \Reliese\Meta\Schema[]
*/
Expand Down Expand Up @@ -107,15 +112,35 @@ 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;
}

/**
* @return bool
*/
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;
}

/**
Expand Down