What is a thin controller?
The concept of the “thin” controller is a guideline to help you avoid having business logic in your presentation layer – it is not as simple as “having more than a little code in controller actions is bad.”
How do I keep my controller thin?
Here are three ways to reduce the logic living in your controllers.
- Remove data access and business logic.
- Use action filters to handle repetitive logic.
- Map your view models using AutoMapper.
Why MVC?
1. Faster development process: MVC supports rapid and parallel development. If an MVC model is used to develop any particular web application then it is possible that one programmer can work on the view while the other can work on the controller to create the business logic of the web application.
Why should you avoid fat models?
While fat models are a little better than fat controllers, they still suffer from the same fundamental issues: when any one of the object’s many responsibilities change, the object itself must change, resulting in those changes propagating throughout the app. Suddenly a minor tweak to a model broke half of your tests!
What is model and controller in laravel?
Laravel applications follow the traditional Model-View-Controller design pattern, where you use: Controllers to handle user requests and retrieve data, by leveraging Models. Models to interact with your database and retrieve your objects’ information. Views to render pages.
What does a controller do in Laravel?
Laravel – Controllers Controllers are meant to group associated request handling logic within a single class. In your Laravel project, they are stored in the app/Http/Controllers’ directory. The full form of MVC is Model View Controller, which act as directing traffic among the Views and the Models.
Why controller is used in Laravel?
Controllers are used to handle the request logic within the single class, and the controllers are defined in the “app/http/Controllers” directory. Laravel framework follows the MVC (Model View Controller) architecture in which controllers act as moving the traffic back and forth between model and views.