Closed darklight9811 closed 4 years ago
Is there any reason that this has to be part of the core and not the user code base? Or maybe a separate package all together?
@thetutlage, actually it could be in a separate package, but I think it should be part of the adonisjs organization, or better, considered an official package, the reasons:
There's already a package by @rhwilr (adonis-bumblebee) that does that well. I don't believe this should be added to the core of the framework.
The reason Laravel does it doesn't I am forced to do it. If you invest some time reading the AdonisJS docs, you will find, you can perform serialization just by using the models.
Also, I suggest opening RFCs with a broader perspective and first try to understand what AdonisJS is and not consider it as a clone of Laravel.
Brief history
Presenters help us format the data from a model/object without altering the object itself. It is just like Laravel API resources, but with a few enhancements.
What problem does it solve?
Presenters help us format the data from a model/object without altering the object itself. It's useful when you want to format it in many different situations presenting different data. Such as paginating/collections, single object, etc.
Proposal
It smartly detects pagination and the object iself.
Abstract class
Example class
Example usage