I am consuming multiple "Restaurant Reviews" REST APIs which return different structures. I need to define a uniform structure for these reviews so I can group them together and deal with them as a collection.
It seems that using Eloquent Resources is on par with what I need.
Looking at the implementation here on this Medium Blog, the method toArray
is used by default when calling return MyResource::make($data)->resolve();
. I do not want to defy the convention of Laravel, since that is why I am using the framework. However, I need all three different structures to have the same uniform ending structures which would lead to lots of if
/ else
and yelpToArray(), foursquareToArray(), etc ...
in the toArray
method.
What is the most "Laravel" way to accomplish this?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2naCeXj
via IFTTT
Aucun commentaire:
Enregistrer un commentaire