Пример #1
0
 public function disablevar($id)
 {
     \DB::beginTransaction();
     //print_r($id); die();
     $variant = Variant::find($id);
     $estado = $variant->estado;
     if ($estado == 1) {
         $variant->estado = 0;
     } else {
         $variant->estado = 1;
     }
     $variant->save();
     \DB::commit();
     return response()->json(['estado' => true]);
 }
Пример #2
0
 public function Paginar_por_Variante()
 {
     $variants = Variant::leftjoin('detAtr', 'variants.id', '=', 'detAtr.variant_id')->join('products', 'products.id', '=', 'variants.product_id')->leftjoin('brands', 'products.brand_id', '=', 'brands.id')->leftjoin('types', 'products.type_id', '=', 'types.id')->leftjoin('materials', 'materials.id', '=', 'products.material_id')->select(\DB::raw('products.id as proId,brands.nombre as BraName,types.nombre as TName,products.codigo as proCodigo,products.nombre as proNombre,products.modelo as modelo,
                           variants.id as varid,variants.sku as varcode,variants.suppPri as varPrice,variants.price as precioProducto,
                            products.hasVariants as TieneVariante,products.created_at as proCreado,brands.id as BraID,materials.id as MId
                           ,materials.nombre as Mnombre,variants.codigo as varCodigo,detAtr.descripcion as descripcion,products.quantVar as proQuantvar,(SELECT GROUP_CONCAT(CONCAT(atributes.shortname,":",detAtr.descripcion) SEPARATOR "/") FROM variants
                             INNER JOIN detAtr ON detAtr.variant_id = variants.id
                             INNER JOIN atributes ON atributes.id = detAtr.atribute_id
                             where variants.id=varid
                             GROUP BY variants.id) as NombreAtributos'))->groupBy('variants.id')->get();
     return $variants;
 }
Пример #3
0
 public function destroy(Request $request)
 {
     //$customer= $this->productRepo->find($request->id);
     \DB::beginTransaction();
     $product = Product::find($request->proId);
     if ($product->hasVariants == 0) {
         $variant = Variant::where('product_id', $product->id)->first();
         $variant->warehouse()->detach();
         $variant->presentation()->detach();
         $variant->delete();
         //die();
         $product->delete();
         //Event::fire('update.customer',$customer->all());
         \DB::commit();
     }
     return response()->json(['estado' => true, 'nombre' => $product->nombre]);
 }