beyondcode/laravel-er-diagram-generator

MorhpTo could not be converted to string

Closed this issue · 8 comments

I have a very small application with 2 classes and they have a one-to-one polymorphic relationship. When removing the $this->morhTo() the diagram is generated, but no matter what I do, adding a polymorphic relationship gives me this error below. I'm using Laravel 5.8.10

Did something change in the latest versions?

`Found 2 models.
Inspecting model relations.
2/2 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%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 /home/felion/doctorapp/vendor/phpdocumentor/graphviz/src/phpDocumentor/GraphViz/Graph.php on line 0
PHP Stack trace:
PHP 1. {main}() /home/felion/doctorapp/artisan:0
PHP 2. App\Console\Kernel->handle() /home/felion/doctorapp/artisan:37
PHP 3. Illuminate\Console\Application->run() /home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:122
PHP 4. Illuminate\Console\Application->run() /home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Console/Application.php:90
PHP 5. Illuminate\Console\Application->doRun() /home/felion/doctorapp/vendor/symfony/console/Application.php:145
PHP 6. Illuminate\Console\Application->doRunCommand() /home/felion/doctorapp/vendor/symfony/console/Application.php:269
PHP 7. BeyondCode\ErdGenerator\GenerateDiagramCommand->run() /home/felion/doctorapp/vendor/symfony/console/Application.php:908
PHP 8. BeyondCode\ErdGenerator\GenerateDiagramCommand->run() /home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Console/Command.php:170
PHP 9. BeyondCode\ErdGenerator\GenerateDiagramCommand->execute() /home/felion/doctorapp/vendor/symfony/console/Command/Command.php:255
PHP 10. Illuminate\Foundation\Application->call() /home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Console/Command.php:183
PHP 11. Illuminate\Container\BoundMethod::call() /home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Container/Container.php:580
PHP 12. Illuminate\Container\BoundMethod::callBoundMethod() /home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:34
PHP 13. Illuminate\Container\BoundMethod::Illuminate\Container{closure:/home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:30-34}() /home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:90
PHP 14. call_user_func_array:{/home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32}() /home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32
PHP 15. BeyondCode\ErdGenerator\GenerateDiagramCommand->handle() /home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32
PHP 16. phpDocumentor\GraphViz\Graph->export() /home/felion/doctorapp/vendor/beyondcode/laravel-er-diagram-generator/src/GenerateDiagramCommand.php:77
PHP 17. phpDocumentor\GraphViz\Graph->__toString() /home/felion/doctorapp/vendor/phpdocumentor/graphviz/src/phpDocumentor/GraphViz/Graph.php:363

Symfony\Component\Debug\Exception\FatalErrorException : 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

at /home/felion/doctorapp/vendor/phpdocumentor/graphviz/src/phpDocumentor/GraphViz/Graph.php:0
1| <?php
2| /**
3| * phpDocumentor
4| *
5| * PHP Version 5
6| *
7| * @author Mike van Riel mike.vanriel@naenius.com
8| * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
9| * @license http://www.opensource.org/licenses/mit-license.php MIT

Exception trace:

1 Symfony\Component\Debug\Exception\FatalErrorException::__construct()
/home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:137

2 Illuminate\Foundation\Bootstrap\HandleExceptions::fatalExceptionFromError()
/home/felion/doctorapp/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:123

Please use the argument -v to see more details.

Whoops\Exception\ErrorException : 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

at /home/felion/doctorapp/vendor/phpdocumentor/graphviz/src/phpDocumentor/GraphViz/Graph.php:0
1| <?php
2| /**
3| * phpDocumentor
4| *
5| * PHP Version 5
6| *
7| * @author Mike van Riel mike.vanriel@naenius.com
8| * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
9| * @license http://www.opensource.org/licenses/mit-license.php MIT

Exception trace:

1 phpDocumentor\GraphViz\Graph::__toString()
/home/felion/doctorapp/vendor/phpdocumentor/graphviz/src/phpDocumentor/GraphViz/Graph.php:363

2 phpDocumentor\GraphViz\Graph::export()
/home/felion/doctorapp/vendor/beyondcode/laravel-er-diagram-generator/src/GenerateDiagramCommand.php:77

`

Hi,

Got the same issue here. Was working before I update to Laravel 5.8.

Same error for me - Laravel 5.8.8, php 7.2.15, macos 10.14.

Same here (Laravel 5.8)

Same issue (Laravel 5.8)

Yahav commented

same, anything?

Yahav commented

#52 solves it.

#52 solves it.

i tried this solution and still the same error "laravel 5.7, php 7.1.9"

package is v1.3, Laravel 5.5 php 7.4 same error