public function GetMainCategory($category) { $category_subCategories = Category::GetSubcategoriesByMainCategoryName($category); if ($category == "brushes") { return Redirect::to("/products/" . $category . "/all_brushes"); } else { if ($category == "accessories") { return Redirect::to("/products/" . $category . "/all_accessories"); } else { if ($category == "artistic") { return Redirect::to("/products/" . $category . "/all_artistic"); } } } if (count($category_subCategories) == 0) { return Redirect::to("/"); } $list_count = count($category_subCategories); $sub_data = array(); for ($i = 0; $i < $list_count; $i++) { $category_name = $category_subCategories[$i]->category_eng_name; $category_bg_name = $category_subCategories[$i]->category_name; $sub_id = $category_subCategories[$i]->sub_category_id; $sub_name = $category_subCategories[$i]->sub_category_name; $sub_eng_name = $category_subCategories[$i]->sub_category_eng_name; $most_popular_products = Product::GetMostPopularSubCatetegoryProducts($sub_id); $newest_products = Product::GetMostRecentSubCatetegoryProducts($sub_id); //TODO: get most popular and most recent products $sub_category_info = array("category_name" => $category_name, "category_bg_name" => $category_bg_name, "sub_id" => $sub_id, "sub_name" => $sub_name, "sub_eng_name" => $sub_eng_name, "most_popular_products" => $most_popular_products, "newest_products" => $newest_products); array_push($sub_data, $sub_category_info); } $data["sub_data"] = $sub_data; return view("category", ["data" => $data]); }