Answer the question
In order to leave comments, you need to log in
Pushing a lot of logic into a model is the Laravel way?
Hello.
A little background: a couple of years ago I undertook to study Yii2 (I quickly stopped this business, because Yii2 is some kind of outrage against common sense), but I remember that there was something about "thick model - thin controller" - and in Laravel , as I see in the examples, all the logic is placed in the controller.
Now I'm doing a project with soft deletion of relations between models and it seems reasonable to me to place the logic of manipulations with relations in the methods of the model.
For example, define a softToggle() method for User to manipulate relations with Role in the User model itself.
How common is this with Laravel?
Or does it not matter at all?
Thank you.
Answer the question
In order to leave comments, you need to log in
in the examples , all logic is placed in the controller.
A framework is a tool for solving your problems. You do not have to adapt to the framework, you need to select the tool that suits your goals.
For good, all your business logic should not depend on the framework at all, and in this regard, Yii and Laravel are not doing very well, but Laravel is at least component-based, and you can customize if you understand what you are doing.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question