Explorar el Código

add value to array

Azam Rezayi hace 4 años
padre
commit
63281548a4
Se han modificado 1 ficheros con 5 adiciones y 25 borrados
  1. 5 25
      packages/product/src/Http/Controllers/ProductController.php

+ 5 - 25
packages/product/src/Http/Controllers/ProductController.php

@@ -200,37 +200,17 @@ class ProductController extends Controller
 //    ****************************uploadGallery********************
     public function uploadValAttribute(Request $request)
     {
+        $attributes=Attribute::orderBy('title')->get();
         $productID = $request->productID;
 //       dd( [$request->val_attribute]);
         $product = Product::where('id', $productID)->first();
         $attributes = [];
-        foreach ( [$request->val_attribute] as $attr_id => $values ){
+        foreach ( $request->val_attribute as $attr_id => $values ){
             $attributes[ $attr_id ] = ['val_attribute' => $values];
 
         }
-//        dd($attributes);
-        $product->attributes()->sync($attributes);
-dd($attributes);
-//        if ((!$attributables->attribute_id='attribute_id' && !$attributables->attributable_id='attributable_id')){
-//            foreach ($info as $item){
-//                $data = [
-//                    'val_attribute' => $item,
-//                    'attribute_id' => $type,
-//                    'attributable_id' => $productID,
-//                    'attributable_type' => 'products',
-//                    'created_at' => Carbon::now(),
-//                    'updated_at' => Carbon::now(),
-//                ];
-//
-//                \DB::table('attributables')->insert($data);
-//            }
-//            $operate['status'] = 200;
-//            $operate['msg'] = 'با موفقیت ذخیره شد !';
-//        }else{
-//            $operate['status'] = 500;
-//            $operate['msg'] = 'اطلاعات قبلا ذخیره شده';
-//        }
-//            return $operate;
-//        }
+//       dd($attributes);
+       $product->attributes()->sync($attributes);
+//dd($attributesd);
     }
 }