Skip to content

Commit

Permalink
Implemented requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
spitfire305 committed Nov 23, 2023
1 parent c35d175 commit 2db8b09
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions app/Http/Resources/EntityResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,21 +202,23 @@ public function entity(array $prepared = [])
$merged['inventory'] = InventoryResource::collection($misc->entity->inventories);
$merged['entity_abilities'] = EntityAbilityResource::collection($misc->entity->abilities);
$merged['entity_assets'] = EntityAssetResource::collection($misc->entity->assets);
}
if ($misc->ancestors) {
$ancestors = [];
foreach ($misc->getAncestors(['id']) as $ancestor) {
$ancestors[] = $ancestor->id;

if ($misc->ancestors) {
$ancestors = [];
foreach ($misc->getAncestors(['id']) as $ancestor) {
$ancestors[] = $ancestor->id;
}
$merged['parents'] = $ancestors;
}
$merged['parents'] = $ancestors;
}
if ($misc->children) {
$descendants = [];
foreach ($misc->children as $descendant) {
$descendants[] = $descendant->id;
if ($misc->children) {
$descendants = [];
foreach ($misc->children as $descendant) {
$descendants[] = $descendant->id;
}
$merged['children'] = $descendants;
}
$merged['children'] = $descendants;
}

$final = array_merge($merged, $prepared);
//ksort($final);
return $final;
Expand Down

0 comments on commit 2db8b09

Please sign in to comment.