public function update(Request $request, Product $Product)
    {
        $validator = Validator::make($request->all(), [
            'id_kategori'=> 'required',
            'id_subkategori'=> 'required',
            'nama_barang'=> 'required',
            'harga'=> 'required',
            'diskon'=> 'required',
            'bahan'=> 'required',
            'tags'=> 'required',
            'sku'=> 'required',
            'ukuran'=> 'required',
            'warna'=> 'required',
            'deskripsi' => 'required',
            'gambar' => 'required|image|mimes:jpg,png,jpeg,webp'
        ]);
        if($validator->fails()) {
            return response()->json(
                $validator->errors(),
                422
            );
        
        }
        $input = $request->all();
        if ($request->has('gambar')) {
            File::delete('uploads/' . $Product->gambar);

            $gambar = $request->file('gambar');
            $nama_gambar = time() . rand(1,9) . '.' . $gambar->getClientOriginalExtension();
            $gambar->move('uploads' , $nama_gambar);
            $input['gambar'] = $nama_gambar;
        }else {
            unset($input['gambar']);
        }
        $Product->update($input);
        return response() -> json([
            'success' => true,
            'message' => 'success',
            'data' => $Product
        ]);
    }