Answer the question
In order to leave comments, you need to log in
How to split models in Laravel?
I am new to Laravel and want to figure out how to organize models. So I created the App/Models folder and the models that are created by Eloquent and work with the database get there.
And where to place models that will have the same name and work with the same entity, but will already contain my methods for working with this entity?
Answer the question
In order to leave comments, you need to log in
Separating models only makes sense if you, for some reason, want to have ActiveRecord separate from the classic concept of a model in MVC. Usually everyone throws everything in a heap, and nothing needs to be divided. Those parts that are responsible for presenting data in responses need to be moved to resources. Scopes, especially if you repeat them, can be put into traits, and heavy, massive functionality, perhaps, will pull on a separate class or even a service.
I'm somewhat jarred by the fact that in some frameworks AR is a model. However, separating their hemorrhoids is unjustified in 98% of cases.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question