public function getCategory($cat_slug = null) { $categories = Categories::where('category_slug', $cat_slug)->lists('id'); // Get Category According to SLUG $allCoupons = Coupons::whereIn('category_id', $categories)->paginate(20); // Get Coupons According to Category Selected $type = 'category'; $data = array('pageTitle' => 'CouponJadu - Get Latest Coupons', 'allCoupons' => $allCoupons, 'allCategories' => $this->allCategories, 'allStores' => $this->allStores, 'type' => $type); return View::make('home', $data); }
public function getForm($id = null) { $dataAdmin = new PrProviders(); $modelProviders = new PrTypes(); $modelCategories = new Categories(); $listProviders = $modelProviders->where('flagactive', PrTypes::STATE_ACTIVE)->lists('name_type', 'id')->toArray(); $listProviders = [null => 'Select un tipo'] + $listProviders; $listCategories = $modelCategories->where('flagactive', Categories::STATE_ACTIVE)->lists('name_category', 'id')->toArray(); $listCategories = [null => 'Select una categoria'] + $listCategories; if (!is_null($id)) { $dataAdmin = PrProviders::find($id); } return viewc('admin.' . self::NAMEC . '.form', compact('dataAdmin', 'listProviders'), ['listCategories' => $listCategories, 'listCategories' => $listCategories]); }
public function searching($term) { $condition = array("New" => 1, "Perfect" => 2, "Good" => 3, "Blemist" => 4); $cond_prod_ids = array(); $product_ids = array(); $pro_ids = array(); $brand_prod_ids = array(); $cat_prod_ids = array(); $tag_prod_ids = array(); //Search by product condition if (in_array($term, $condition)) { $cond_prod_ids = Product::where("condition", "=", $condition[$term])->lists('products_id'); } //Search by product attribute name $product_values_ids = ProductsOptionsValues::where('products_options_values_name', 'LIKE', '%' . $term . '%')->lists('products_options_values_id'); if ($product_values_ids) { $product_ids = DB::table('bn_products_attributes')->whereIn('options_values_id', $product_values_ids)->lists('products_id'); } //Search by product name or description $pro_ids = ProductsDescription::where('products_name', 'LIKE', '%' . $term . '%')->orWhere('products_description', 'LIKE', '%' . $term . '%')->lists('products_id'); //Search by product brand $brand_ids = Brands::where('brand_name', 'LIKE', '%' . $term . '%')->lists('brands_id'); if ($brand_ids) { $brand_prod_ids = Product::whereIn("brand", $brand_ids)->lists('products_id'); } //Search product by category $cat_ids = Categories::where('title', 'LIKE', '%' . $term . '%')->lists('categories_id'); if ($cat_ids) { $cat_prod_ids = DB::table('bn_products_to_categories')->whereIn('categories_id', $cat_ids)->lists('products_id'); } //Search product by tags $tag_ids = Tags::where('title', 'LIKE', '%' . $term . '%')->lists('tags_id'); if ($tag_ids) { $tag_prod_ids = DB::table('bn_products_to_tags')->whereIn('tags_id', $tag_ids)->lists('products_id'); } $result_prod_ids = array_merge($product_ids, $cond_prod_ids, $pro_ids, $brand_prod_ids, $cat_prod_ids, $tag_prod_ids); $products = Product::whereIn('products_id', $result_prod_ids)->where('products_status', '1')->paginate(15); //->get(); if ($products) { $products = $this->product_add_detail($products); return $this->response(array('statusCode' => 100, 'statusDescription' => 'Success', 'products' => json_decode($products->toJson(), true))); } else { return $this->response(array('statusCode' => 400, 'statusDescription' => 'Not Found')); } }
public function show_subcategories($id) { $Category = Categories::where('parent_id', '=', $id)->get(); return $this->response(array('statusCode' => 100, 'statusDescription' => "Success", 'categories' => json_decode($Category, true))); }