Hi there, I am using Ember.js (http://emberjs.com/) for developing most of my frontend-applications and now using it in combination with Laravel as the backend, providing the REST-API.
There is one 'problem' though, when I want to provide a resource that includes a many-to-many relationship. So the code would be something like, Model::with(array('relationship1', 'relationship2')->get()->toArray(); and so far I am providing the resource via Response::json(compact('model')), which works when I provide simple models, but ember.js expects relationships to be sideloaded in a different way as provided here:
http://emberjs.com/guides/models/connecting-to-an-http-server/#toc_json-conventions
Is there any simple way of making Laravel provide my resources with relationships in that format? Right now I am creating the JSON response manually, which is quite tedious. Would be extremely helpful if anyone knows a better way. Thanks for any help.
Check out the package rtablada/eloquent-ember
That should do what you want.
Thank you my dear sir. That could have saved me hours of work yesterday.
I gave up on ember. To frustrating, but the package is awesome!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community