public function product_search(Request $request)
 {
     $this->setMetadata('Tìm kiếm tin đăng');
     $product_type_id = $request->input('product_type');
     $province_id = $request->input('province');
     $district_id = $request->input('district');
     $ward_id = $request->input('ward');
     $street_id = $request->input('street');
     $price_range_id = $request->input('price');
     $area_range_id = $request->input('area');
     $incense_type_id = $request->input('incense');
     $limit = Config::findByKey('rows_per_page_product')->first()->value;
     $searchDescription = "";
     $product_type = null;
     $province = null;
     $district = null;
     $ward = null;
     $street = null;
     $query = Product::query();
     try {
         if (isset($product_type_id) && $product_type_id != "") {
             $query->where('product_type_id', $product_type_id);
             $product_type = product_type::findOrFail($product_type_id);
             $searchDescription .= $product_type->name;
         }
         if (isset($province_id) && $province_id != "") {
             $query->where('province_id', $province_id);
             $province = Province::findOrFail($province_id);
             $searchDescription .= ", " . $province->name;
         }
         if (isset($district_id) && $district_id != "") {
             $query->where('district_id', $district_id);
             $district = District::findOrFail($district_id);
             $searchDescription .= ", " . $district->name;
         }
         if (isset($ward_id) && $ward_id != "") {
             $query->where('ward_id', $ward_id);
             $ward = Ward::findOrFail($ward_id);
             $searchDescription .= ", " . $ward->name;
         }
         if (isset($street_id) && $street_id != "") {
             $query->where('street_id', $street_id);
             $street = Street::findOrFail($street_id);
             $searchDescription .= ", " . $street->name;
         }
     } catch (Exception $e) {
     }
     $products = $query->paginate($limit);
     $product_types = Product_type::where('active', 1)->orderBy('priority')->orderBy('created_at', 'desc')->get();
     $hcmProvince = Province::findByKey('ho-chi-minh')->first();
     // dd($hcmProvince->id);
     $districtProduct = District::where('province_id', '=', $hcmProvince->id)->where('is_publish', 1)->orderBy('priority')->orderBy('created_at', 'desc')->get();
     return view('frontend.sites1.product_search', ['products' => $products, 'product_types' => $product_types, 'districtProduct' => $districtProduct, 'searchDescription' => $searchDescription]);
 }
 public function __construct($params = array(), $get_assoc = true, $get_attached = true)
 {
     global $db;
     parent::__construct($params, $get_assoc, $get_attached);
 }
示例#3
0
function getOptPType($sId = '', $parent = 'root')
{
    $ct = new product_type();
    $ct->setWhere("parent='" . $parent . "'");
    $temp = $ct->getList();
    if ($sId == 'root') {
        $str = '<option value="root" selected >主目錄</option>';
    } else {
        $str = '<option value="root">主目錄</option>';
    }
    foreach ($temp as $key => $val) {
        if ($val['id'] == $sId) {
            $str .= '<option value="' . $val['id'] . '" selected >&nbsp;&nbsp;' . $val['title'] . '</option>';
        } else {
            $str .= '<option value="' . $val['id'] . '" >&nbsp;&nbsp;' . $val['title'] . '</option>';
        }
    }
    return $str;
}