public function index()
 {
     //
     Visitor::log();
     $cats = Categories::orderBy('sort_id', 'asc')->get();
     $products = Products::orderBy('sort_id', 'asc')->get();
     Setting::get('config.mainprod', Null) ? $mainProdImg = asset('/files/img/' . Setting::get('config.mainprod')) : ($mainProdImg = asset('dist/img/photo4.jpg'));
     Setting::get('config.logo', Null) ? $logoMain = asset('/files/img/' . Setting::get('config.logo')) : ($logoMain = asset('dist/img/logo.png'));
     $topProds = DB::table('order_items')->select('product_id', DB::raw('count(*) as total'))->groupBy('product_id')->orderBy('total', 'desc')->take('5')->get();
     $topProdsArr = [];
     foreach ($topProds as $topprod) {
         if (!in_array($topprod->product_id, ['fast', 'np', 'gift'])) {
             if (strpos($topprod->product_id, '0000')) {
                 //dd('consist');
                 $pID = explode('0000', $topprod->product_id);
                 //$topprod->product_id = $pID[0];
                 $prodID = $pID[0];
             } else {
                 $prodID = $topprod->product_id;
             }
             $prodName = Products::findOrFail($prodID);
             //echo $prodName->name;
             array_push($topProdsArr, ['name' => $prodName->name, 'cover' => $prodName->cover, 'link' => $prodName->urlhash]);
         }
         // code...
     }
     //dd(collect($topProdsArr));
     $data = ['cats' => $cats, 'products' => $products, 'PageDescr' => Setting::get('config.maindesc'), 'PageWords' => Setting::get('config.mainwords'), 'PageAuthor' => '', 'PageTitle' => Setting::get('config.maintitle'), 'mainProdImg' => $mainProdImg, 'logoMain' => $logoMain, 'topProds' => $topProdsArr, 'totalNavLabel' => $this->totalNavLabel()];
     return view('catalogPage')->with($data);
 }
Exemple #2
0
 public function indexSitemap()
 {
     //$date=LocalizedCarbon::parse($order->created_at)->format('d M Y H:i:s');
     //Sitemap::addSitemap('/catalog');
     Sitemap::addtag(URL::to('/'), date('Y-m-d H:i:s'));
     Sitemap::addtag(URL::to('/gallery'), date('Y-m-d H:i:s'));
     Sitemap::addtag(URL::to('/catalog'), date('Y-m-d H:i:s'));
     Sitemap::addtag(URL::to('/info'), date('Y-m-d H:i:s'));
     $cats = Categories::all();
     foreach ($cats as $cat) {
         Sitemap::addtag(URL::to('/' . $cat->urlhash), $cat->updated_at, 'daily', '0.8');
     }
     $products = Products::all();
     foreach ($products as $product) {
         Sitemap::addtag(URL::to('/' . $product->urlhash . '.html'), $product->updated_at, 'daily', '0.8');
     }
     //$sitemap = App::make("sitemap");
     //$sitemap->add(URL::to('/'), date('Y-m-d H:i:s'), '1.0', 'daily');
     return Sitemap::renderSitemap();
 }
Exemple #3
0
 public function ShortLinkCategory($id)
 {
     Visitor::log();
     $cat = Categories::whereUrlhash($id)->firstorfail();
     $cats = Categories::orderBy('sort_id', 'asc')->get();
     //
     Setting::get('config.mainprod', Null) ? $mainProdImg = asset('/files/img/' . Setting::get('config.mainprod')) : ($mainProdImg = asset('dist/img/photo4.jpg'));
     Setting::get('config.logo', Null) ? $logoMain = asset('/files/img/' . Setting::get('config.logo')) : ($logoMain = asset('dist/img/logo.png'));
     $topProds = DB::table('order_items')->select('product_id', DB::raw('count(*) as total'))->groupBy('product_id')->orderBy('total', 'desc')->take('5')->get();
     $topProdsArr = [];
     foreach ($topProds as $topprod) {
         if (!in_array($topprod->product_id, ['fast', 'np', 'gift'])) {
             $prodName = Products::findOrFail($topprod->product_id);
             //echo $prodName->name;
             array_push($topProdsArr, ['name' => $prodName->name, 'cover' => $prodName->cover, 'link' => $prodName->urlhash]);
         }
         // code...
     }
     $products = Products::orderBy('sort_id', 'asc')->whereCategories_id($cat->id)->get();
     //dd($products );
     $data = ['cats' => $cats, 'products' => $products, 'PageDescr' => Setting::get('config.maindesc'), 'PageWords' => Setting::get('config.mainwords'), 'PageAuthor' => '', 'PageTitle' => Setting::get('config.maintitle') . ' - ' . $cat->name, 'mainProdImg' => $mainProdImg, 'logoMain' => $logoMain, 'topProds' => $topProdsArr, 'category' => $cat, 'totalNavLabel' => $this->totalNavLabel()];
     return view('catalogPageOne')->with($data);
 }
Exemple #4
0
 public function editProduct($id)
 {
     //
     $product = Products::findOrFail($id);
     //dd($product->recommendProd);
     $myprod = $product->recommendProd;
     $myprods_arr = [];
     foreach ($myprod as $key => $value) {
         //$myprods_arr[] = $value->id;
         array_push($myprods_arr, $value->product_id_recommend);
     }
     $cats = Categories::orderBy('sort_id', 'asc')->get();
     $prods = Products::orderBy('sort_id', 'asc')->get();
     $cats_arr = [];
     foreach ($cats as $key => $value) {
         $cats_arr[$value->id] = $value->name;
     }
     $prods_arr = [];
     foreach ($prods as $key => $value) {
         $prods_arr[$value->id] = $value->name;
     }
     //dd($prods_arr);
     $product->isset == 'false' ? $product->isset = Null : $product->isset;
     //dd($product->isset);
     $data = ['CatList' => $cats_arr, 'Prods' => $prods_arr, 'myProds' => $myprods_arr, 'product' => $product, 'NewOrderCounter' => Purchase::Neworders()->count()];
     return view('admin.content.productEdit')->with($data);
 }