Closed ahren-condos-ca closed 5 years ago
Also, if I try run php artisan generate:erd erd-test.txt --format=text -vvv
it works.
Further tried removing large models just to try get it working. Completes byt throws this error: 127/127 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% 1 min/1 min 144.2 MiB"App\ViewingRequest" PHP Fatal error: Method BeyondCode\ErdGenerator\Edge::__toString() must not throw an exception, caught ErrorException: Object of class Illuminate\Database\Eloquent\Relations\MorphTo could not be converted to string in /var/www/api/vendor/phpdocumentor/graphviz/src/phpDocumentor/GraphViz/Graph.php on line 0
@ahren-condos-ca have you installed the graphviz
package ?
Yup. If I use the config file to limit my project to only a few models, it then works. However there are few models that when included cause the above error. Most importantly this happens for my User Model which is a big issue.
Still stuck on the above error pertaining to Morphable model relationships (Photos) and dont know what to look for next.
On a side note: One of the issues i have been able to work around is the use of https://github.com/jenssegers/laravel-mongodb (adds MongoDB support for some models) which was throwing errors due too it not having implemented a needed function which i inserted a try - catch in this repo's code and just use the default table_name.field_name pattern.
So I've further been able to troubleshoot but it appears that the library doesn't support Morphable models, which like in my Photo Model case, contains fields model_type and model_id columns. The class then has a function
public function model()
{
return $this->morphTo();
}
This class then throws an Exception Object of class Illuminate\Database\Eloquent\Relations\MorphTo could not be converted to string
on
./vendor/beyondcode/laravel-er-diagram-generator/src/Edge.php:55
From what I can tell this simply doesn't not handle the morthTo() case since fromPort and toPort don't seem to have values.
wrapping lines 54 in your Edge.php class with a try catch I was able to prevent the crash. Not sure if you can figure a better solution but for now this works fo me
try{
$from_name .= (!empty($this->fromPort)) ? ':' . $this->fromPort : '';
$to_name .= (!empty($this->toPort)) ? ':' . $this->toPort : '';
} catch (\Exception $e) {return '';}
seems to have been fixed in latest version with Pivot and morphable mapping improvements
php artisan generate:erd -vvv Found 148 models. Inspecting model relations. 148/148 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% 51 mins/51 mins 1.9 GiB In Graph.php line 375:
[phpDocumentor\GraphViz\Exception]: syntax error in line 1213 near '->'
An error occurred while creating the graph; GraphViz returned: Error:
Exception trace: () at /var/www/api/vendor/phpdocumentor/graphviz/src/phpDocumentor/GraphViz/Graph.php:384 phpDocumentor\GraphViz\Graph->export() at /var/www/api/vendor/beyondcode/laravel-er-diagram-generator/src/GenerateDiagramCommand.php:77 BeyondCode\ErdGenerator\GenerateDiagramCommand->handle() at n/a:n/a call_user_func_array() at /var/www/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29 Illuminate\Container\BoundMethod::Illuminate\Container{closure}() at /var/www/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87 Illuminate\Container\BoundMethod::callBoundMethod() at /var/www/api/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31 Illuminate\Container\BoundMethod::call() at /var/www/api/vendor/laravel/framework/src/Illuminate/Container/Container.php:564 Illuminate\Container\Container->call() at /var/www/api/vendor/laravel/framework/src/Illuminate/Console/Command.php:179 Illuminate\Console\Command->execute() at /var/www/api/vendor/symfony/console/Command/Command.php:255 Symfony\Component\Console\Command\Command->run() at /var/www/api/vendor/laravel/framework/src/Illuminate/Console/Command.php:166