Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[BugFix] avoid backpack:build to generate interfaces for abstract models and others #146
[BugFix] avoid backpack:build to generate interfaces for abstract models and others #146
Changes from 2 commits
1c134f1
e1f9860
0aacf2c
5410827
679eb91
a7b4306
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
When we have the class, why we don't reflect on it ?
If the reflection fails we are sure it's not a model, if the reflection works we can check if it's a
$reflection->isSubclassOf()
(or something similar), and reflection also let us check if it's abstract with$reflection->isAbstract()
.I think using reflection would also remove the need for:
// Try to load it form file content
scenario.Let me know what you think.
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.
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.
Changed to Reflection 👌
Much better, it also prevents crashes due to errors on the files 👌
Regarding the need of
// Try to load it form file content
there may be situations where we can't infer class from file path.In these cases (maybe others), we need to try to load them from parsing the file content right?
Let me know @pxpm 🙌
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.
Wouldn't this become a non-issue if we have the paths and namespaces configurable?
I think something like this:
This way the config would say:
app_path('Models')
and it should use the base namespaceApp\Models
. We should recursively find models in that directiory, eg:App\Models\Auth\User
,App\Models\Blog\Post
.app/packages
that also have models, I want them, but the base namespace isVendor/Package
.It would work for everyone and every project by changing the configs ... the defaults could be "permissive", but I could configure it other way if needed.
Let me know what you guys think @promatik @tabacitu
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.
Configurable model paths is beyond the scope of this PR. And if you ask me - beyond the scope of Generators. DevTools? Sure, that's easier to use. But Generators?... nah.
Let's not expand the scope please.