I would add the date and formatted date values in the API resources.
Jun 6, 2024
2
Level 4
Where To Format?
I'm using Laravel, with Api Resources and Inertia.
I need to format some of my data, for example date formatting for humans.
I considered doing it JS side, but as the same data appears in several places I want consistency.
So where to put it? Model accessor? Api Resource? Somewhere else?
Not, I cannot overwrite the original value, as I still need to retain it (for the date example, it may need editing by the user).
Please or to participate in this conversation.