【Design Pattern】Transformer

Posted by 西维蜀黍 on 2023-01-10, Last Modified on 2023-05-02

Transformers

Transformers contain the business logic for changing a model’s format to whatever you need for the output, whether that’s HTML, Datatable, or JSON API. Decoupling this logic from the model allows for unobtrusive schema changes, a reliable place for housing formatting logic, and data formatting operations outside of views (for example, converting a date, or performing translations).

Reference