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 index() { $breadcrumbs = [["name" => "home", "url" => "/"], ["name" => "producten", "url" => "/producten"]]; $categories = []; foreach (MainCategory::with('sub_categories')->get() as $val) { array_push($categories, $val); } return view('products/index')->with(array("categories" => $categories, "breadcrumbs" => $breadcrumbs)); }