In this article, we will see examples of various previously-described design patterns used in Laravel.

The topics that will be discussed in this chapter are as follows:

  • Basic and advanced practices
  • Real-life examples of design patterns used in Laravel
  • The reasons why these design patterns are used in the examples

Basic practices

As a developer, when you are working on an application, there should be a systematic order to things to prevent confusion and allow flexibility. For example, in an MVC architecture, Controller should only hold the logic and Model should only hold dataflow-related stuff. You should not write database queries in View files. This way, anyone working on the project can find what they are looking for easily and can change, fork, or improve it with greater ease. If this is not followed, the project will turn into a mess as it gets bigger and bigger.