本文整理匯總了PHP中app\Product::attributes方法的典型用法代碼示例。如果您正苦於以下問題:PHP Product::attributes方法的具體用法?PHP Product::attributes怎麽用?PHP Product::attributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Product
的用法示例。
在下文中一共展示了Product::attributes方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: saveAttributes
/**
* 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);
}
示例2: product
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]);
}
示例3: updateProduct
/**
* Update a product.
*
* @param ProductRequest $request
*/
private function updateProduct(ProductRequest $request, Product $product)
{
$product->update($request->all());
$product->attributes()->sync($this->syncArray($request));
}
示例4: attributes
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()];
}