Skip to content
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

support for App\Models namespace #5

Open
screenager opened this issue Jul 13, 2021 · 5 comments
Open

support for App\Models namespace #5

screenager opened this issue Jul 13, 2021 · 5 comments

Comments

@screenager
Copy link

When looking into HomeController getModels(), I think the package is only scanning the App/ directory, and not App/Models.
Perhaps make this configurable?

@JhumanJ
Copy link
Owner

JhumanJ commented Jul 14, 2021

It's not how it works. I built the package with all my model in App/Models. It scans all the classes loaded and only gets the one extending the Model class. Could you please give more details about your exact issue?

https://github.com/JhumanJ/laravel-model-stats/blob/main/src/Http/Controllers/HomeController.php#L29

@screenager
Copy link
Author

Could be 2 issues here indeed.
My models extend a parent class, before that one extends Model.

So File::allFiles(app_path() does a deep search ? Perhaps I didn't debug this well.

Whereas isSubclassOf(Model::class) does not look one level higher?

@JhumanJ
Copy link
Owner

JhumanJ commented Jul 15, 2021

I've just done a test where I have a model A extending a class B (itself extending model), and it worked just fine. Can you share details about your environment, and give more details about how to reproduce the issue?

@screenager
Copy link
Author

screenager commented Jul 23, 2021

Did some more debugging. I think being able to specify the models directory, and only scan that models directory, is a better solution for big projects with a lot of deprecated code.

In my case, getModels() fails on scanning some unused Console/Commands (with a broken dependency) and some other helper files (that aren't real classes with namespaces).

@AbdullahFaqeir
Copy link
Contributor

I shall take a look at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants