laravel-shift / blueprint

A code generation tool for Laravel developers.
MIT License
2.82k stars 270 forks source link

Fix Issue #685: Corrections and Improvements in Model and Migration Generation #694

Open AaronLil opened 1 month ago

AaronLil commented 1 month ago

This pull request addresses the problem reported in issue #685 and includes a series of corrections and enhancements to the generation process for both models and migrations in the Blueprint package.

Key Corrections and Enhancements:

  1. Model Generation:

    • Corrected method naming issues for relationships involving columns with non-standard Laravel naming conventions.
    • Fixed duplicate method names for multiple relationships to the same table.
    • Ensured proper handling of foreign key references, including support for Fully Qualified Names (FQNs) and custom relationship names.
    • Refined logic to avoid method name collisions and to respect Laravel's naming conventions.
  2. Migration Generation:

    • Ensured accurate handling of table and column specifications, including correct generation of foreign keys and relationships.
    • Enhanced processing of column attributes to correctly handle nullable and other modifiers.
    • These changes significantly improve the reliability and adherence to Laravel standards in the generation processes, addressing both the specific issues reported and enhancing overall functionality.

These updates have been tested thoroughly to ensure compatibility and correctness, and we believe they will provide a more robust and predictable experience for Blueprint users.

jasonmccreary commented 1 month ago

Looks like the build is broken. Not sure if this is your code or existing. Either way, it'd be good to see some tests around the changes you made.

AaronLil commented 1 month ago

I don't know much about testing and phpunit, but I'll take a look. It's probably just a matter of adapting the tests to the new internal relationship syntax.