/**
  * Creates, updates or deletes the attributes.
  *
  * @param Product $product
  */
 protected function saveAttributes(Product $product)
 {
     $ids = [];
     foreach (array_filter($this->attributes) as $attribute_id => $value) {
         $ids[$attribute_id] = compact('value');
     }
     $product->attributes()->sync($ids);
 }
Exemple #2
0
 public function product(Shop $shop, Product $product)
 {
     $user = Auth::user();
     $attributes = $product->attributes()->with('attribute_group')->get();
     $types = $attributes->unique('attribute_group_id');
     $product->visit();
     return view('shop.product', compact('shop', 'product', 'types', 'attributes', 'user'))->with(['title' => $product->name]);
 }
 /**
  * Update a product.
  *
  * @param ProductRequest $request
  */
 private function updateProduct(ProductRequest $request, Product $product)
 {
     $product->update($request->all());
     $product->attributes()->sync($this->syncArray($request));
 }
Exemple #4
0
 public function attributes(Shop $shop, Product $product, Request $request)
 {
     $product->attributes()->create($request->all());
     return ['hasCallback' => '1', 'callback' => 'product_attribute_add', 'hasMsg' => 1, 'msg' => 'added successfully', 'returns' => $product->attributes()->with('Attribute_group')->get()];
 }