eloquent-json-relations: Relationship queries fail for string Ids
Hi. The package works wonderfully and has been nothing short of incredible since discovering it. I noticed though, that relationship queries fail when used with records that have ids of random strings (as is the case in some parts of my implementation) instead of the expected integer.
As an example, a relation defined like so:
public function collectedScrap()
{
return $this->belongsToJson(CollectedScrap::class, 'collection_ids->collection_id');
}
where the collection_ids is an array of ids that are of six random letters and numbers:
["IJSM9","JSN3HG","HYSH7T"]
returns an empty array. I would like to know if the package even supports this behaviour and how I might go about implementing a workaround if it doesn’t.
Thanks.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 28 (13 by maintainers)
Oh, that was the problem. It works fine now. Thanks for the assistance.
In your data, there is no
location_idskey, butcoverage_zone_coordinatesitself contains the related IDs.I only see
location_idsas a completely separate attribute.With this data structure, the relationship needs to be: