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));
 }