Clients have a morphMany() relationship to Addresses.
Route:
{{host}}/api/v1/addresses
Body:
{
"data" : {
"type": "addresses",
"attributes": {
},
"relationships": {
"clients": {
"data": {
"type": "clients",
"id": "2"
}
}
}
}
}
Error:
Cannot insert the value NULL into column 'addressable_type', table 'OmegaMCS.dbo.addresses'; column does not allow nulls. INSERT fails.
Here's what was missing.
On the JSON API Address Adapter:
protected function addressable() {
return $this->belongsTo();
}
In the Address request:
"relationships": {
"addressable": {
"data": {
"type": "clients",
"id": "2"
}
}
}
@dobbie004 good to see that you solved it yourself. Relationships (especially poly ones) can be quite a pain in the neck. :sweat_smile:
Feel free to close the issue if it has been resolved. :v:
Yes sorry I didn't have a chance to reply over the weekend, but glad to hear that you found the missing piece to get it working!!
Most helpful comment
Here's what was missing.
On the JSON API Address Adapter:
In the Address request: