public function edit(Product $product) { //GENERAL $textures = Texture::with("colours")->get(); $categories = []; foreach (MainCategory::with('sub_categories')->get() as $val) { array_push($categories, $val); } $colours = ProductColour::all(); $colourArray = []; foreach ($colours as $colour) { $colourArray[] = "'" . $colour->code . "'"; } // $detail_preview_img = ProductPhoto::where("product_id", "=", $product->id)->where("is_preview", "=", 1)->first(); $tmp_array = []; $colour_photos = ProductPhoto::where("product_id", "=", $product->id)->where("is_colour_img", "=", 1)->get(); foreach ($colour_photos as $item) { $pivot = DB::table('photos_colours')->where("photo_id", "=", $item->id)->first(); $item->colour = ProductColour::find($pivot->colour_id); $tmp_array[] = $item; } $product->colour_images = $tmp_array; $edit_textures = DB::table('product_textures')->where("product_id", "=", $product->id)->get(); $textures_edit_array = []; foreach ($edit_textures as $item) { $result = Texture::with("colours")->where("id", "=", $item->texture_id)->get(); $textures_edit_array[] = $result; } $preview_images = ProductPhoto::where("product_id", "=", $product->id)->where("is_detail_preview", "=", 1)->get(); $product->sub_categories; // $product["textures"] = $product->product_textures()->get(); return view('cms/product/product/edit')->with(array('item' => $product, "categories" => $categories, "textures" => $textures, "colours" => $colourArray, "rawColours" => json_encode($colours), "detail_preview_img" => $detail_preview_img, "preview_images" => $preview_images, "edit_textures" => $textures_edit_array)); }
public function edit(Texture $texture) { $colours = ProductColour::all(); $colourArray = []; foreach ($colours as $colour) { $colourArray[] = "'" . $colour->code . "'"; } return view('cms/texture/edit')->with(array('item' => $texture, "colours" => $colourArray, "rawColours" => json_encode($colours))); }
public function detail(Product $product) { $breadcrumbs = [["name" => "home", "url" => "/"], ["name" => "producten", "url" => "/producten"], ["name" => $product->title, "url" => "/producten/" . $product->id]]; $detail_preview_photos = DB::table('product_photos')->where("product_id", "=", $product->id)->where("is_detail_preview", "=", 1)->get(); //if product has preview photos, show first preview photo on initial load. Else show colour images if (count($detail_preview_photos) > 0) { $product->colour_img = $detail_preview_photos[0]; } else { $firstColourImg = DB::table('product_photos')->where("product_id", "=", $product->id)->where("is_colour_img", "=", 1)->first(); //COLOUR IMAGE if ($firstColourImg) { $privot_photo_colour_first = DB::table('photos_colours')->where("photo_id", "=", $firstColourImg->id)->first(); $product->colour_img = $firstColourImg; $firstColour = ProductColour::find($privot_photo_colour_first->colour_id); $product->colour = $firstColour; //TEXTURE $textures = DB::table('textures')->where("colour_id", "=", $firstColour->id)->get(); if ($textures) { foreach ($textures as $texture) { $tmp = DB::table('product_textures')->where("product_id", "=", $product->id)->where('texture_id', '=', $texture->id)->get(); if ($tmp) { $product->texture = Texture::find($tmp[0]->texture_id); break; } } } } } if ($detail_preview_photos) { $product->detail_preview_photos = $detail_preview_photos; } //get all available colours for this product through colour images $available_colours_array = []; $colourImagesOfProduct = DB::table('product_photos')->where("product_id", "=", $product->id)->where("is_colour_img", "=", 1)->get(); foreach ($colourImagesOfProduct as $colourImage) { $privot_photo_colour_first = DB::table('photos_colours')->where("photo_id", "=", $colourImage->id)->first(); $colour = ProductColour::find($privot_photo_colour_first->colour_id); $available_colours_array[] = $colour; } //all font colour $font_colours = ["#252b5a", "#293477", "#3f509e", "#4a69b1", "#273575", "#262d5f", "#191b36", "#f18515", "#f49919", "#fab432", "#f2a202", "#b96b15", "#c49209", "#d1870c", "#fcc72f", "#edd48c", "#fdc50a", "#ffda10", "#fae514", "#aa8b12", "#433014", "#671725", "#c53c3d", "#f08176", "#f4a3ac", "#d1312f", "#ed6f24", "#9a2417", "#032f2d", "#1d411d", "#95c15f", "#275c29", "#498331", "#0f754b", "#5fb87f", "#1d4b4e", "#8cc9ba", "#0a8880", "#319abb", "#2680a2", "#8fb6e2", "#c83256", "#eb5a6a", "#c83159", "#ea5093", "#ef7fa1", "#ef81a4", "#932162", "#65236a", "#b596c6", "#7b4594", "#6c2477", "#412b86", "#322873", "#777dbb", "#8e70a6", "#767cbb", "#431d4b", "#27170d", "#8c6215", "c8b26f", "#422529", "#aa9796", "#c0b9b5", "#75463d", "#6b3e46", "#999083", "#e3a365", "#973d15", "#492911", "#dddccf", "#dbdbda", "#989799", "#1d1d1b"]; return view('products/detail')->with(array("product" => $product, "breadcrumbs" => $breadcrumbs, "available_colours" => $available_colours_array, "font_colours" => $font_colours)); }
public function delete(ProductColour $product) { $product->delete(); return redirect('/cms/colour'); }