diff --git a/src/GraphBuilder.php b/src/GraphBuilder.php index 765c184..f311c65 100644 --- a/src/GraphBuilder.php +++ b/src/GraphBuilder.php @@ -17,7 +17,7 @@ class GraphBuilder * @param $models * @return Graph */ - public function buildGraph(Collection $models) : Graph + public function buildGraph(Collection $models): Graph { $this->graph = new Graph(); @@ -32,40 +32,23 @@ public function buildGraph(Collection $models) : Graph protected function getTableColumnsFromModel(EloquentModel $model) { - try { - - $table = $model->getConnection()->getTablePrefix() . $model->getTable(); - $schema = $model->getConnection()->getDoctrineSchemaManager($table); - $databasePlatform = $schema->getDatabasePlatform(); - $databasePlatform->registerDoctrineTypeMapping('enum', 'string'); - - $database = null; - - if (strpos($table, '.')) { - list($database, $table) = explode('.', $table); - } - - return $schema->listTableColumns($table, $database); - } catch (\Throwable $e) { - } - - return []; + return \Schema::getColumns($model->getTable()); } protected function getModelLabel(EloquentModel $model, string $label) { $table = '<' . PHP_EOL; - $table .= '' . PHP_EOL; + $table .= '' . PHP_EOL; if (config('erd-generator.use_db_schema')) { $columns = $this->getTableColumnsFromModel($model); foreach ($columns as $column) { - $label = $column->getName(); + $label = $column['name']; if (config('erd-generator.use_column_types')) { - $label .= ' ('.$column->getType()->getName().')'; + $label .= ' (' . $column['type'] . ')'; } - $table .= '' . PHP_EOL; + $table .= '' . PHP_EOL; } } @@ -193,7 +176,8 @@ protected function connectBelongsToMany( ); $this->connectNodes($pivotModelNode, $relatedModelNode, $relation); - } catch (\ReflectionException $e){} + } catch (\ReflectionException $e) { + } } /**
' . $label . '
' . $label . '
' . $label . '
' . $label . '