Why developers should avoid the usage of Eloquent in your Laravel Controllers!

What are disadvantages of using Eloquent or database queries in your Laravel controllers?

  • Single Responsibility Principle — your controllers have extra responsibility of managing the database
  • Dependency Inversion Principle — your controllers worry about how to persist data, instead of knowing when to persist it.
  • DRY — as soon as you add more controllers / queue workers you will be copy — pasting the same logic everywhere

Infrastructure Layer in Laravel

Leave a Reply

Your email address will not be published. Required fields are marked *