Exemplo n.º 1
2
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(ProductRequest $request)
 {
     //
     $data = $request->all();
     if (isset($data['image'])) {
         $thumb = $data['image'];
         $new = 'pro' . uniqid() . '.' . $thumb->getClientOriginalExtension();
         $thumb->move('upload/product', $new);
     }
     $data['image'] = $new;
     $productId = Product::addProduct($data);
     $multi_image = Input::file('multi-images');
     foreach ($multi_image as $multi) {
         # code...
         $thumbnail = 'multi' . uniqid() . '.' . $multi->getClientOriginalExtension();
         $multi->move('upload/multi-image', $thumbnail);
         Image::addImage($productId, $thumbnail);
     }
     if (Input::get('color') != "") {
         $color = Input::get('color');
         foreach ($color as $colorId) {
             # code...
             MapColor::mapColor($colorId, $productId);
         }
     }
     if ($data['other_color'] != "") {
         $other = $data['other_color'];
         $colorId = Color::addColor($other);
         MapColor::mapColor($colorId, $productId);
     }
     if (Input::get('size') != "") {
         $size = Input::get('size');
         foreach ($size as $sizeId) {
             # code...
             MapSize::mapSize($sizeId, $productId);
         }
     }
     if ($data['other_size'] != "") {
         $other = $data['other_size'];
         $sizeId = Size::addSize($other);
         MapSize::mapsize($sizeId, $productId);
     }
     return redirect('admin/product');
     //return "ok";
 }
Exemplo n.º 2
0
 public static function getSize($id)
 {
     return MapSize::where('product_id', $id)->get();
 }
Exemplo n.º 3
0
 public function detail($id)
 {
     $product = Product::find($id);
     $rel = new Product();
     $img = Image::getImage($id);
     $color = Color::all();
     $size = Size::all();
     $mapColor = MapColor::getColor($id);
     $mapSize = MapSize::getSize($id);
     $cat = category::all();
     $rateAvg = Comment::getAvg($id);
     $count = Comment::getCount($id);
     $review = Comment::getreviewProduct($id);
     $relative = $rel->getRelative($product->category_id, $id);
     $obj = new category();
     // navbar
     $nav = new category();
     $menu_top = $nav->menu_top($nav->all()->toArray());
     $temp = array("id" => $product->id, "name" => $product->name, "thumbnail" => $product->image, "price" => $product->price);
     $data = Session::get('cookie');
     //$data[$product->id]=$temp;
     if (is_null($data)) {
         $data[$product->id] = $temp;
     } elseif (isset($data[$product->id])) {
         unset($data[$product->id]);
         $data[$product->id] = $temp;
     } else {
         $data[$product->id] = $temp;
     }
     Session::put('cookie', $data);
     $menu = $obj->menu_left($obj->all()->toArray());
     return view('frontend.pages.subpages.detail', array('menu_top' => $menu_top, 'product' => $product, 'relative' => $relative, 'cat' => $cat, 'rateAvg' => $rateAvg, 'count' => $count, 'review' => $review, 'menu' => $menu, 'img' => $img, 'color' => $color, 'size' => $size, 'mapColor' => $mapColor, 'mapSize' => $mapSize));
 }