Laravel: Service Layer with DTOs and Validators
An example of how to have a Service Layer with DTOs using Laravel Validator.
What is a Service Layer?
A Service Layer is a design pattern. Design patterns are common solutions in software design.
This one abstracts our domain logic. It delegates the application logic to common services.
It is a way of moving to skinny controllers, helping us not to repeat code, avoiding to have everything in the controller.
Need to return JSON and HTML from the controllers? Ideas on how this could be acomplished.
This layer is usually placed between controllers and repositories, and it is common to have the concerns of file system access, database access, or email sending.
If you would like to see an example of this service layer implementation, check out this article using Unsplash API with a Service Layer and DTOs.