Example #1
0
 public static function getBrand($prod)
 {
     $brands = array_flatten(\App\Models\Category::findBySlug("brand-name")->getDescendants(1, ['id'])->toArray());
     $prodCats = array_flatten($prod->categories()->get(['cat_id'])->toArray());
     @($brand = array_flatten(array_intersect($brands, $prodCats))[0]);
     return $brand;
 }
Example #2
0
 public function createSlug($title, $numb = 0)
 {
     $slug = str_slug($title, '-') . ($numb ? '-' . $numb : '');
     $already = Category::findBySlug($slug);
     if ($already->count()) {
         return $this->createSlug($title, $numb + 1);
     }
     return $slug;
 }
Example #3
0
 public function index($slug)
 {
     $category = Category::findBySlug($slug);
     $sizes = array_flatten(Attribute::where("attr", "Shoe Size")->first()->attributeoptions()->select('option_name')->get()->toArray());
     $parts = scandir(public_path() . "/Frontend/shoes/" . $category->folder);
     $parts = array_diff($parts, array('.', '..'));
     $savedList = User::find(Session::get('user')->id)->savedlist;
     //print_r($savedList);
     return view(Config('constants.frontView') . '.design', compact('category', 'parts', 'sizes', 'savedList'));
 }
Example #4
0
 public function getFilters($slug)
 {
     $currentCat = Category::findBySlug($slug);
     if (!$currentCat) {
         $currentCat = Category::findBySlug("shop");
     }
     $filters = ["id" => $currentCat->id, "category" => "Categories", "child" => $currentCat->getDescendants(1, ['id', 'category'])->toHierarchy()];
     $cats = Category::roots()->where("url_key", "!=", 'shop')->where("url_key", "!=", "popular")->get()->toHierarchy();
     foreach ($cats as $cat) {
         $cat->child = $cat->getDescendants(1, ['id', 'category'])->toHierarchy();
     }
     $cats = $cats->toArray();
     array_unshift($cats, $filters);
     return response()->json($cats);
 }
 public function index($slug = null)
 {
     $category = Category::findBySlug($slug)->first();
     $products = Product::categorized($category)->paginate(8);
     return view('admin.products.index')->with('categories', Category::tree())->with('products', $products);
 }
Example #6
0
 public function getNewProds()
 {
     $products = Product::where("is_individual", 1)->orderBy("id", "desc")->paginate(8);
     foreach ($products as $prd) {
         $attrs = [];
         foreach ($prd->categories()->where("url_key", "!=", "popular")->get() as $cat) {
             $pcat = $cat->getAncestors()->toArray();
             $attrs[$pcat[0]['category']] = $cat->category;
         }
         $prd->tags = $prd->tagged;
         $prd->attrs = $attrs;
         $prd->image = $prd->catalogimgs()->first();
         @($prd->image->filename = asset(Config('constants.productImgPath') . @$prd->image->filename));
         if (Session::get("userId") && User::find(Session::get("userId"))->savedlist->contains($prd->id)) {
             $prd->saved = 1;
         } else {
             $prd->saved = 0;
         }
     }
     $products = $products->toArray();
     $products['maincat'] = Category::findBySlug("popular")->category;
     return response()->json($products);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($slug)
 {
     $cat = Category::findBySlug($slug);
     $pages = $cat->pages()->paginate(10);
 }