public function getProductsByCategoryKey($categoryKey = '', $limit = 0)
 {
     $productCategory = ProductCategory::where('key', $categoryKey)->first();
     if (isset($productCategory) && !is_null($productCategory)) {
         if ($limit == 0) {
             return $productCategory->products()->where('is_publish', 1)->orderBy('priority')->orderBy('created_at', 'desc')->get();
         } else {
             return $productCategory->products()->where('is_publish', 1)->orderBy('priority')->orderBy('created_at', 'desc')->take($limit)->get();
         }
     }
     return [];
 }
예제 #2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($id = null)
 {
     if ($id === null) {
         return view('product-main', ['categories' => $this->categories, 'title' => LANG . '_title', 'description' => LANG . '_description', 'tech_description' => LANG . '_tech_description', 'text' => LANG . '_text']);
     }
     $category = ProductCategory::find($id);
     if (!$category) {
         $category = ProductCategory::where('alias', $id)->first();
     }
     if ($category) {
         return view('catalog', ['categories' => $this->categories, 'selectedCategory' => $category, 'objects' => Product::where('product_category_id', '=', $category->id)->paginate(9), 'title' => LANG . '_title', 'description' => LANG . '_description', 'tech_description' => LANG . '_tech_description', 'text' => LANG . '_text', 'seo_title' => LANG . '_seo_title', 'seo_description' => LANG . '_seo_description', 'seo_keywords' => LANG . '_seo_keywords']);
     }
     return redirect(LANG . '/catalog');
 }
 public function fetchAllActive()
 {
     return ProductCategory::where(['is_active' => '1'])->orderBy('name', 'asc')->get();
 }