recca0120 / laravel-erd

Laravel ERD automatically generates Entity-Relationship Diagrams from your Laravel models and displays them using erd-editor.
MIT License
205 stars 8 forks source link

Check if method is relation before invoking #12

Open SimonJnsson opened 6 days ago

SimonJnsson commented 6 days ago

Right now, all methods on a given model is invoked, potentially causing issues. This PR checks if the return type of the method is a subclass og EloquentRelation, before attempting to invoke the function, avoiding calls to methods that are not relations.

recca0120 commented 4 days ago

Hi @SimonJnsson Yes, you’re right. However, in my case, I frequently encounter methods without return types. This is why I switched the database to SQLite and invoked methods to retrieve the return types.

SimonJnsson commented 2 days ago

Hey @recca0120, that makes a lot of sense. Maybe we can use the current approach as a fallback if the method has no return type specified?