Hi Tim, great work on your package. It makes implementing the JSON:API spec a breeze. Please I have a issue with the adding relationships section. I think I followed the docs verbatim but the outcome is different.
So this is from my controller
$flow = QueryBuilder::for(Flow::class)
->allowedIncludes(['items'])->find($flowId);
if (null === $flow) {
return new NotFound();
}
return new OK(
message: __('responses.ok.show', ['resourceType' => 'flow']),
data: FlowResource::make($flow)
);
class FlowItemResource extends JsonApiResource
{
/**
* @return array<string, mixed>
*/
public function toAttributes(Request $request): array
{
return [
'sort_order' => $this->sort_order,
'request_id' => $this->request_id,
];
}
}
But in my response I have no included section rather I have
array:2 [
"message" => "Get flow."
"data" => array:4 [
"id" => "01hx1c998n7asa2zc707ea0f7b"
"type" => "flows"
"attributes" => array:4 [
"name" => "maiores"
"description" => "Delectus distinctio corporis et odit quia quas dolor. Iste qui non libero et et expedita. Qui et dolorum perspiciatis et sed soluta."
"num_requests" => 683068
"num_views" => 434863
]
"relationships" => array:1 [
"items" => array:1 [
"data" => array:5 [
0 => array:2 [
"type" => "flowItems"
"id" => "01hx1c99av13hcag94hr0wwdnb"
]
1 => array:2 [
"type" => "flowItems"
"id" => "01hx1c99av13hcag94hr0wwdnc"
]
2 => array:2 [
"type" => "flowItems"
"id" => "01hx1c99awfs77jg58tj52whdv"
]
3 => array:2 [
"type" => "flowItems"
"id" => "01hx1c99awfs77jg58tj52whdw"
]
4 => array:2 [
"type" => "flowItems"
"id" => "01hx1c99awfs77jg58tj52whdx"
]
]
]
]
]
]
In the docs link there was a included section with the full data from the relationships section. Please can you help me point out what I may be doing wrong?
Hi Tim, great work on your package. It makes implementing the JSON:API spec a breeze. Please I have a issue with the
adding relationships
section. I think I followed the docs verbatim but the outcome is different.So this is from my controller
Then in my FlowResource I have:
Then in my FlowItemResource I have:
But in my response I have no included section rather I have
In the docs link there was a included section with the full data from the relationships section. Please can you help me point out what I may be doing wrong?