コード例 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $product_types = ['Căn hộ bán', 'Căn hộ sang nhượng', 'Căn hộ cho thuê'];
     $product_types_meta_description = ['Bán căn hộ. Căn hộ chính chủ, sổ hồng, căn hộ chất lượng, cập nhật thông tin mua bán căn hộ mới nhất trên khắp các tỉnh thành Hồ Chí Minh, Hà Nội, Đà nẵng, Bình Dương', 'Căn hộ sang nhượng', 'Căn hộ cho thuê'];
     $product_types_meta_keywords = ['Bán căn hộ, bán căn hộ quận 2, căn hộ chính chủ, căn hộ sổ hồng.', 'Căn hộ sang nhượng', 'Căn hộ cho thuê'];
     foreach ($product_types as $key => $value) {
         $product_type = Product_type::create(['key' => Common::createKeyURL($value), 'name' => $value, 'priority' => $key, 'meta_description' => $product_types_meta_description[$key], 'meta_keywords' => $product_types_meta_keywords[$key], 'active' => 1, 'created_by' => 'vankhoe', 'updated_by' => 'vankhoe']);
     }
 }
コード例 #2
0
 public function getProductsByTypeKey($typeKey = '', $limit = 0)
 {
     $product_type = Product_type::where('key', $typeKey)->first();
     if (isset($product_type) && !is_null($product_type)) {
         if ($limit == 0) {
             return $product_type->products()->where('active', 1)->orderBy('priority')->orderBy('created_at', 'desc')->get();
         } else {
             return $product_type->products()->where('active', 1)->orderBy('priority')->orderBy('created_at', 'desc')->take($limit)->get();
         }
     }
     return [];
 }
コード例 #3
0
 /**
  * List Product type ajax.
  */
 public function getProductType(Request $request)
 {
     $product_types = Product_type::where('active', 1)->orderBy('priority')->orderBy('created_at', 'desc')->get();
     return $product_types->toArray();
 }
コード例 #4
0
 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]);
 }
コード例 #5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     DB::transaction(function () use($id) {
         $user = Auth::user();
         $product_type = Product_type::findOrFail($id);
         $product_type->updated_by = $user->name;
         $product_type->deleted_by = $user->name;
         $product_type->key = $product_type->key . '-' . microtime(true);
         $product_type->save();
         // soft delete
         $product_type->delete();
     });
 }