Refactor resource mapping in resources() method
This commit is contained in:
parent
6688120aee
commit
8b9548a463
@ -22,6 +22,16 @@ public function resources(Request $request)
|
||||
$resources->push($projects->pluck(str($db)->plural(2))->flatten());
|
||||
}
|
||||
$resources = $resources->flatten();
|
||||
$resources = $resources->map(function ($resource) {
|
||||
$payload = $resource->toArray();
|
||||
if ($resource->getMorphClass() === 'App\Models\Service') {
|
||||
$payload['status'] = $resource->status();
|
||||
} else {
|
||||
$payload['status'] = $resource->status;
|
||||
}
|
||||
$payload['type'] = $resource->type();
|
||||
return $payload;
|
||||
});
|
||||
return response()->json($resources);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user