protected function recurse($subtree, $relation, $depth, $last)
{
$padding = '';
if ($depth > 1) {
for ($i = 0; $i < $depth - 1; $i++) {
$padding .= ($last ? ' ' : '│') . ' ';
}
}
if ($depth === 0) {
$line = "";
} else {
$line = ($last ? '└─' : '├─') . " ";
}
$table_name = $subtree['name'];
$relations = $subtree['relations'];
$rel = '';
if ($this->option('relations') && $relation) {
$from_field = $relation['from_field'];
$to_field = $relation['to_field'];
$rel = " [{$from_field} --> {$to_field}]";
}
$this->line("{$padding}{$line}{$table_name}{$rel}");
foreach ($relations as $i => $relation) {
$this->recurse($relation['table'], $relation, $depth + 1, $i === count($relations) - 1);
}
}