I have a matrix with a field to set a Entries URL. Unfortunately the entry is not being returned, only an empty object.
Here are my field settings below and element api code.
See below for the response within the json. I get an empty object?
Why is no data coming through?
I'm fetching the data within a function like so:
Here is the code from my Element API:
function panelsMatrix($array) {
$panelBlocks = [];
foreach ($array as $block) {
switch ($block->type->handle) {
case 'panel':
$panelBlocks[] = [
'heading' => (string) $block->heading,
'text' => (string) $block->text,
'image' => $block->image[0]->url,
'imagePosition' => $block->imagePosition,
'textBaseColour' => $block->textBaseColour,
'textHorizontalAlignment' => $block->textHorizontalAlignment,
'textVerticalAlignment' => $block->textVerticalAlignment,
'imageOffsetX' =>$block->imageOffsetX,
'imageOffsetY' =>$block->imageOffsetY,
'backgroundColour' => $block->backgroundColour,
'subPageDirect' => $block->subPageDirect->first()
];
break;
}
}
return $panelBlocks;
}