/** * PRODUCT_TYPE vs PROVINCE vs DISTRICT vs WARD */ public function product_type_province_district_ward($product_type_key, $province_key, $district_key, $ward_key, Request $request) { $ward = Ward::findByKey($ward_key)->first(); if (is_null($ward)) { $ward = Ward::where('is_publish', 1)->orderBy('priority')->orderBy('created_at', 'desc')->first(); } $district = $ward->district; $province = $district->province; $price_ranges = Price_range::where('active', 1)->orderBy('priority')->orderBy('created_at', 'desc')->get(); $area_ranges = Area_range::where('active', 1)->orderBy('priority')->orderBy('created_at', 'desc')->get(); $incense_types = Incense_type::where('active', 1)->orderBy('priority')->orderBy('created_at', 'desc')->get(); $limit = Config::findByKey('rows_per_page_product')->first()->value; $product_type = Product_type::findByKey($product_type_key)->first(); if (is_null($product_type)) { $product_type = Product_type::where('active', 1)->orderBy('priority')->orderBy('created_at', 'desc')->first(); } $products = Product::where('product_type_id', $product_type->id)->where('district_id', $district->id)->where('active', 1); $project_id = $request->input('project'); $price_range_id = $request->input('price'); $area_range_id = $request->input('area'); $incense_type_id = $request->input('incense'); if (isset($project_id) && $project_id != '') { $products->where('project_id', $project_id); } if (isset($price_range_id) && $price_range_id != '') { $products->where('price_range_id', $price_range_id); } if (isset($area_range_id) && $area_range_id != '') { $products->where('area_range_id', $area_range_id); } if (isset($incense_type_id) && $incense_type_id != '') { $products->where('incense_type_id', $incense_type_id); } $products = $products->orderBy('priority')->orderBy('created_at', 'desc')->paginate($limit); $searchDescription = $product_type->name . ' ' . $province->name . ' ' . $district->name . ' ' . $ward->name; $link = route('product_type_province_district_ward', ['product_type_key' => $product_type->key, 'province_key' => $province->key, 'district_key' => $district->key, 'ward_key' => $ward->key]); $breadcrumb = '<ul class="breadcrumb"> <li class="active"><a href="' . route('homepage') . '">Trang chủ</a></li> <li class="active"><a href="' . route('products') . '">Căn hộ</a></li> <li class="active"><a href="' . route('product_type', ['product_type_key' => $product_type->key]) . '">' . $product_type->name . '</a></li> <li class="active"><a href="' . route('product_type_province', ['product_type_key' => $product_type->key, 'province_key' => $province->key]) . '">' . $province->name . '</a></li> <li class="active"><a href="' . route('product_type_province_district', ['product_type_key' => $product_type->key, 'province_key' => $province->key, 'district_key' => $district->key]) . '">' . $district->name . '</a></li> <li class=""><a href="' . $link . '">' . $ward->name . '</a></li> </ul>'; $heading = $product_type->name . ' ' . $province->name . ' ' . $district->name . ' ' . $ward->name; $this->setMetadata($searchDescription); return view('frontend.sites1.product_search', ['products' => $products, 'product_type' => $product_type, 'district' => $district, 'price_ranges' => $price_ranges, 'area_ranges' => $area_ranges, 'incense_types' => $incense_types, 'search_type' => 'product_type_province_district', 'link' => $link, 'searchDescription' => $searchDescription, 'breadcrumb' => $breadcrumb, 'heading' => $heading]); }