-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created a positiblity to add custom relation type #987
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO looks good to move forward with tests
Thanks :)
Co-authored-by: Markus Podar <[email protected]>
Is this something we can/should solve via reflection? Perhaps that is difficult, though. We would need to search through each method, and see if the return type is a subtype of |
It might not be the perfect solution at the moment. Not all code uses a strict return type. The linked library for example hasn't implemented them yet, so reflection might be a great addition to get rid of the mapping for types methods. As fallback I suggest to keep the config option |
Personally I would reduce the time invested, the config approach seems a pragmatic approach. I bet it doesn't come up often. First time I hear about this requirement in years 😄 |
I've looked into the source from Laravel. The relations don't have a return type. So the reflection would need Parsing of the return type of the doc block. This isn't ideal. |
Only Problem I see in the config approach, may be two libraries modifying the config. For future extension it might be helpful to create a HelperClass for adding class mappings to the config property. Please review the Test. I'm not sure everything is covert. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@barryvdh LGTM!
# Conflicts: # config/ide-helper.php # src/Console/ModelsCommand.php # tests/Console/ModelsCommand/Relations/Test.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm it has conflicts again |
# Conflicts: # CHANGELOG.md
@barryvdh fixed! We'll likely see this more often now with the changelog, adding entries at the top I fear… |
* Created a positiblity to add custom relation type * Changed access modifier Co-authored-by: Markus Podar <[email protected]> * fixed hints from code review * Added Test for barryvdh/laravel-ide-helper#987 * composer fix-style * Clarify doc in config entry * Update CHANGELOG.md Co-authored-by: Markus Podar <[email protected]>
* Created a positiblity to add custom relation type * Changed access modifier Co-authored-by: Markus Podar <[email protected]> * fixed hints from code review * Added Test for barryvdh/laravel-ide-helper#987 * composer fix-style * Clarify doc in config entry * Update CHANGELOG.md Co-authored-by: Markus Podar <[email protected]>
* Created a positiblity to add custom relation type * Changed access modifier Co-authored-by: Markus Podar <[email protected]> * fixed hints from code review * Added Test for barryvdh/laravel-ide-helper#987 * composer fix-style * Clarify doc in config entry * Update CHANGELOG.md Co-authored-by: Markus Podar <[email protected]>
* Created a positiblity to add custom relation type * Changed access modifier Co-authored-by: Markus Podar <[email protected]> * fixed hints from code review * Added Test for barryvdh/laravel-ide-helper#987 * composer fix-style * Clarify doc in config entry * Update CHANGELOG.md Co-authored-by: Markus Podar <[email protected]>
* Created a positiblity to add custom relation type * Changed access modifier Co-authored-by: Markus Podar <[email protected]> * fixed hints from code review * Added Test for barryvdh/laravel-ide-helper#987 * composer fix-style * Clarify doc in config entry * Update CHANGELOG.md Co-authored-by: Markus Podar <[email protected]>
In a project of mine I use the eloquent-has-many-deep library. To enable the ide-helper for it, I wrote a possibility to add a config option to add custom relation types.
I know the code isn't tested yet. I'll add it as soon as the idea of the pull request has been discussed.