/**
  * Display a listing of the resource.
  * GET /categories
  *
  * @return Response
  */
 public function index($path)
 {
     $slug = explode('/', $path);
     $category = Category::where('slug', end($slug))->first();
     $wares = Ware::where('category_id', $category->id)->paginate(12);
     $this->layout->content = View::make('page.category', compact('category', 'wares'));
 }
Beispiel #2
0
 public function waresImportStore()
 {
     if (Input::hasFile('importFile')) {
         $file = Input::file('importFile');
         $filePath = public_path('uploads/imports/' . date('Y/m/d'));
         $fileName = Str::random('3') . $file->getClientOriginalName();
         $file->move($filePath, $fileName);
         $excel = Excel::load("{$filePath}/{$fileName}", function ($reader) {
         })->get();
         foreach ($excel as $item) {
             $ware = Ware::where('article', $item->sku)->first();
             if (!$ware) {
                 $ware = new Ware();
                 $ware->slug = Slug::make($item->name) . Str::random(8);
             }
             $ware->article = $item->sku;
             $ware->slug = Slug::make($item->name);
             $ware->title = $item->name;
             $ware->price = $item->list_price;
             $ware->discount = $item->sell_price;
             $ware->save();
         }
         return 'ok';
     }
 }
Beispiel #3
0
 public function ajaxCart()
 {
     $ware = Ware::find(Input::get('wareId'));
     Cart::associate('Ware')->add(['id' => Input::get('wareId'), 'name' => $ware->title, 'qty' => 1, 'price' => $ware->price - $ware->discount]);
     return Cart::count();
 }