Рет қаралды 256
As you might already know Laravel is PHP framework which follow MVC (Model View Controller) architecture pattern. And we went over the View and model parts In the previous couple of lessons.
Now in this lesson we're going to learn another part of MVC which is Controller. In theory Controller is responsible for controlling the execution flow of the application. It acts as a directing traffic between Views and Models
The controller receives an input from the users and makes calls to model and the view to perform appropriate actions.
Although in practise we can control the execution flow in our routes as we done so far, but that way could be OK if our code only contain a simple logic. As our application grows, the logic could become more complex and our code could become larger and larger. That's why doing that way may not ideal.
That's why it's better to put our code into controller. This will make your code better organized and easy to maintain.