Skip to content
Advertisement

create API for multidimensonal array using category, subcategory and further subcategory laravel

I have to create API for dynamic menu used in react js. The menu contains catgeory, subcategory and further subcategory. I have created the code, but it is not working as expected.

The required output is,

JavaScript

The code I have used to create the above result is,

JavaScript

But the above code is not getting the required output. The output for the above code is,

JavaScript

fsubcategory is outside subcategory. How to get the required output. How to modify the code to achieve the correct result. I am really stuck here.

Advertisement

Answer

I have got the answer,

JavaScript

This will provide the required output

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement