Hi All ... i am new to Laravel. I read a concept of Skinny Controller and Fat Model. By using Eloquent, we need to access model in Controller to store/get/update/delete and due to that our Controller become bigger than model. So how can we achieve this thing in our project ?
For update and create I have in controller, but the retrieval of data (list and view) I have query scopes in modal.
But you could if you wanted put the actual updating and inserting of data in the model.
But I don't, because it's usually just another line of code to save.
You can move certain behaviour from the Controller to the Model if you see that said behaviour should be the model's responsibility. You could also extract the validation to FormRequests, complex queries to Repositories, simple queries to Model Scopes, etc.
Maybe if you paste the code of one of your controllers some of the experienced users could give specific suggestions on how to improve it.
It depends on what your controller and models have to do.
If you're just doing simple manipulations (create, read, update, delete), then yes, probably your controllers would be a little bigger than your models, because you will handle there validation, filling, saving, etc. And that's fine.
But when the app grows, the rule "Slim Controllers, Fat Models" just tell us to move business logics in Models keeping Controllers small.
Imagine you have to do more complicated manipulations, for instance performing calculations and updating multiple tables when a record is created, then you should move all these things in your models.