JhumanJ / laravel-model-stats

Model statistics dashboard for your Laravel Application
MIT License
240 stars 18 forks source link

support for App\Models namespace #5

Open screenager opened 3 years ago

screenager commented 3 years ago

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

JhumanJ commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

I shall take a look at this.