A free open source IT asset/license management system
fix api show method for custom labels
Godfrey Md9c8c49ce92a
diff --git a/app/Http/Controllers/Api/LabelsController.php b/app/Http/Controllers/Api/LabelsController.phpindex 496cd11068..0476cd716d 100644--- a/app/Http/Controllers/Api/LabelsController.php+++ b/app/Http/Controllers/Api/LabelsController.php@@ -77,16 +77,22 @@ class LabelsController extends Controller*/public function show(string $labelName): JsonResponse|array{- $customLabel = CustomUserLabel::find($labelName);+ if (str_starts_with($labelName, 'custom:')) {+ $customLabelId = (int)str_replace('custom:', '', $labelName);- if ($customLabel) {- $this->authorize('view', $customLabel);+ $customLabel = CustomUserLabel::find($customLabelId);- return (new LabelsTransformer)->transformLabels(- collect([[- 'source' => 'custom',- 'label' => $customLabel,- ]]), 1);+ if ($customLabel) {+ $this->authorize('view', $customLabel);++ return (new LabelsTransformer)->transformLabels(+ collect([[+ 'source' => 'custom',+ 'label' => $customLabel,+ ]]),+ 1+ );+ }}$labelName = str_replace('/', '\\', $labelName);