I have very complex functions in laravel APIs ( called from Mobile App). The sample function is given below. If someone can help to improve the code structure. I wish to kno