Closed yoelpc4 closed 5 years ago
Currently my solution is adding relation name in adapter's fillable array, is this the right solution?
Hi!
So I haven't look through this issue in detail, but yes you would need to add it to the fillable array. That's because it is typical for Eloquent models to not have their relationships as fillable, so you would need to specify them as fillable on your JSON API adapter to get round that.
Is it working when you add it to your fillable array? If so, can probably close this issue!
Hi @lindyhopchris , I've encountered a problem while creating a comments resource which has belongs to commentator (users resource) and belongs to post (posts resource) with this package information
"cloudcreativity/laravel-json-api": "^1.4"
I received 500 "Internal Server Error" because user_id and post_id are not filled while creating comment record in database.
Before submitting this issue I've tried your debugging tips from similar issue #359 , but nothing seems wrong in my codes.
Here's some gists to helping you understanding my problem.
JSON API v1 Configuration https://gist.github.com/yoelpc4/68e861288ca8da1e9ad28f68b69ce1e7
API routes https://gist.github.com/yoelpc4/a6f9a727a6f2418c513002572d65212b
Comment Migration https://gist.github.com/yoelpc4/57bf6b77624305d889d74646df0a1cc4
Comment Model https://gist.github.com/yoelpc4/399d50fd711ac005b001d5ffc6729dd9
Users Adapter https://gist.github.com/yoelpc4/34e2d676286a81623c7ca40f6542fd82
Posts Adapter https://gist.github.com/yoelpc4/5bb744fc085d6deb7e7d42331489ab69
Comments Adapter https://gist.github.com/yoelpc4/759e113b278dc5b11ec569de8d59b1a5
Comments Validators https://gist.github.com/yoelpc4/ea1b225aab7a2a9c7d8b96d747bed943
Request URL https://zenith.test/api/v1/comments?include=commentator,post.author
Request Method POST
Request payload
Debugging result from create method AbstractResourceAdapter.php ln. 89 $document parameter
$parameters parameter
Debugging result from fillAndPersist method AbstractResourceAdapter ln.306 $record parameter
$resource parameter
$record after
beforePersist
invocationSo I believe this is the end of debugging result, because whenever I dumping $async after
persist
invocation, there's no more output and this is the query exception.