Skip to content

Commit

Permalink
#1 Pivot naming
Browse files Browse the repository at this point in the history
Using studly version of pivot table name when label is "Pivot" rather than use custom intermediate table class names.
  • Loading branch information
w0rd-driven committed Sep 9, 2021
1 parent de3b7d5 commit 90a80df
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
5 changes: 4 additions & 1 deletion src/GraphBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ protected function connectBelongsToMany(
$pivotModel->setTable($eloquentRelation->getTable());
$label = (new \ReflectionClass($pivotClass))->getShortName();
$pivotTable = $eloquentRelation->getTable();
if ($label == "Pivot") {
$label = \Str::studly($pivotTable);
}
$this->addNodeToGraph($pivotModel, $pivotTable, $label);

$pivotModelNode = $this->graph->findNode($pivotTable);
Expand Down Expand Up @@ -216,4 +219,4 @@ protected function connectByRelation(

$this->connectNodes($modelNode, $relatedModelNode, $relation);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
Inspecting model relations.
1/4 [▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░] 25%
2/4 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░] 50%
3/4 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░] 75%
4/4 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%digraph "G" {
style="filled"
bgcolor="#F7F7F7"
Expand Down Expand Up @@ -134,7 +132,7 @@
]
"comment_user" [
label=<<table width="100%" height="100%" border="0" margin="0" cellborder="1" cellspacing="0" cellpadding="10">
<tr width="100%"><td width="100%" bgcolor="#d3d3d3"><font color="#333333">Pivot</font></td></tr>
<tr width="100%"><td width="100%" bgcolor="#d3d3d3"><font color="#333333">CommentUser</font></td></tr>
</table>>
margin="0"
shape="rectangle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
Inspecting model relations.
1/4 [▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░] 25%
2/4 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░] 50%
3/4 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░] 75%
4/4 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%digraph "G" {
style="filled"
bgcolor="#F7F7F7"
Expand Down Expand Up @@ -155,7 +153,7 @@
]
"comment_user" [
label=<<table width="100%" height="100%" border="0" margin="0" cellborder="1" cellspacing="0" cellpadding="10">
<tr width="100%"><td width="100%" bgcolor="#d3d3d3"><font color="#333333">Pivot</font></td></tr>
<tr width="100%"><td width="100%" bgcolor="#d3d3d3"><font color="#333333">CommentUser</font></td></tr>
<tr width="100%"><td port="id" align="left" width="100%" bgcolor="#ffffff"><font color="#333333" >id</font></td></tr>
<tr width="100%"><td port="comment_id" align="left" width="100%" bgcolor="#ffffff"><font color="#333333" >comment_id</font></td></tr>
<tr width="100%"><td port="user_id" align="left" width="100%" bgcolor="#ffffff"><font color="#333333" >user_id</font></td></tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
Inspecting model relations.
1/4 [▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░] 25%
2/4 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░] 50%
3/4 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░] 75%
4/4 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%digraph "G" {
style="filled"
bgcolor="#F7F7F7"
Expand Down Expand Up @@ -155,7 +153,7 @@
]
"comment_user" [
label=<<table width="100%" height="100%" border="0" margin="0" cellborder="1" cellspacing="0" cellpadding="10">
<tr width="100%"><td width="100%" bgcolor="#d3d3d3"><font color="#333333">Pivot</font></td></tr>
<tr width="100%"><td width="100%" bgcolor="#d3d3d3"><font color="#333333">CommentUser</font></td></tr>
<tr width="100%"><td port="id" align="left" width="100%" bgcolor="#ffffff"><font color="#333333" >id (integer)</font></td></tr>
<tr width="100%"><td port="comment_id" align="left" width="100%" bgcolor="#ffffff"><font color="#333333" >comment_id (integer)</font></td></tr>
<tr width="100%"><td port="user_id" align="left" width="100%" bgcolor="#ffffff"><font color="#333333" >user_id (integer)</font></td></tr>
Expand Down

0 comments on commit 90a80df

Please sign in to comment.