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

Handle abstract model classes #4

Merged
merged 1 commit into from Sep 13, 2022

Conversation

Riley19280
Copy link
Contributor

@Riley19280 Riley19280 commented Sep 13, 2022

In our application, we have an abstract base model that contains many helper methods. Due to the model finder trying to create a new instance of all classes that extend Model, a Cannot instantiate abstract class App\Models\BaseModel exception gets thrown. This PR filters out the abstract models from being returned from the model finder.

Testing is covered via the can discover all models in a directory test, as I added an abstract model to the Models folder, and the count is still remains 3

@freekmurze freekmurze merged commit c43b884 into spatie:main Sep 13, 2022
@freekmurze
Copy link
Member

Thank you!

@Riley19280 Riley19280 deleted the bugfix/abstract-model branch September 13, 2022 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants