4 months ago

Using Response()->json from Helpers

Posted 4 months ago by KishorKurian


I am trying to make a REST API backend for my app.

To keep the API outputs same format from all places, I am using a helper with statis functions, to which I send errors and outputs and the functions prints it for me.

I would like to use response()->json from the helper file. I am not able to. I dont get any errors, but I dont see any outputs either. Should I add something in the use statement to be able to use it?

I made helper class myself. so please let me know whats wrong.

Also Is this a good approach? The backend will have considerable number of controllers which output data, which is why I made a helper instead of formatting it every time,

Please sign in or create an account to participate in this conversation.