public function getProductsavailable($id) { if (!empty($id)) { $getsubusers = Userproductaccess::where('upa_ud_user_id', $id)->get(); if (count($getsubusers) > 0) { foreach ($getsubusers as $getsubuserss) { $getproducts[] = Commonmodel::getproducts($getsubuserss->upa_prod_code); $getcatcode[] = Commonmodel::getcatcode($getsubuserss->upa_prod_code); } $category = array_unique($getcatcode); foreach ($category as $categorys) { $getcat[] = Commonmodel::getcategory($categorys); } $getcat = array_filter($getcat); $getcatmultidemisional = Commonmodel::is_multi2($getcat); if (empty($getcatmultidemisional)) { $final_category = Commonmodel::converarray2to1($getcat); } elseif (!empty($getcatmultidemisional)) { $final_category = $getcat; } else { $final_category = array(); } $getproductsmultidemsional = Commonmodel::is_multi2($getproducts); if (empty($getproductsmultidemsional)) { $final_products = Commonmodel::converarray2to1($getproducts); } elseif (!empty($getproductsmultidemsional)) { $final_products = $getproducts; } else { $final_products = array(); } return Response::json(array('categories' => $final_category, 'message' => 'Products fetched', 'status' => 'success', 'products' => $final_products)); } else { return Response::json(array('status' => 'failure', 'message' => 'You Don"t have Access to Any Products')); } } else { return Response::json(array('status' => 'failure', 'message' => 'Fill All Manditary Fields')); } }