cloudcreativity / laravel-json-api

JSON API (jsonapi.org) package for Laravel applications.
http://laravel-json-api.readthedocs.io/en/latest/
Apache License 2.0
780 stars 109 forks source link

Add support for model bindings in route params #506

Closed benkingcode closed 4 years ago

benkingcode commented 4 years ago

I noticed when I set my url.namespace to api/v1/{tenant}, if the tenant param was bound to a model the generated URLs would contain the JSON serialization, like so;

"links": {
    "self": "http:\/\/api.example.test\/api\/v1\/{\"id\":1,\"name\":\"Tenant Name\",\"created_at\":\"2020-04-20T13:57:55.000000Z\",\"updated_at\":\"2020-04-20T13:57:55.000000Z\",\"slug\":\"test-slug\"}\/products\/1"
}

With this fix, bound models correctly use the route key;

"links": {
    "self": "http:\/\/api.example.test\/api\/v1\/test-slug\/products\/1"
}
benkingcode commented 4 years ago

Cool, made your suggested change! The tests all passed locally for me so not sure why Travis is showing a failure.

lindyhopchris commented 4 years ago

Thanks! Looks like a temporary failure - knowing Laravel they probably had something breaking in their releases which they've then fixed.