本文整理匯總了PHP中app\models\Product::update方法的典型用法代碼示例。如果您正苦於以下問題:PHP Product::update方法的具體用法?PHP Product::update怎麽用?PHP Product::update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Product
的用法示例。
在下文中一共展示了Product::update方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: handle
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
// /**
// * Create Product
// */
// $product = $product->create([
// 'name' => $this->request->get('name'),
// 'code' => $this->request->get('code'),
// 'image' => $this->moveFile($this->image, '/image/products/', 'figurine'),
// ]);
//
// /**
// * Create Product Profile
// */
// $product->profile()->create([
// 'description' => $this->request->get('description'),
// 'image' => $this->moveFile($this->poster, '/image/products/', 'poster')
// ]);
$this->product->update(['name' => $this->request->get('name'), 'code' => $this->request->get('code'), 'image' => $this->files->has('image') ? $this->moveFile($this->files->get('image'), '/image/products/', 'figurine') : $this->product->image]);
$this->product->profile->update(['description' => $this->request->get('description'), 'image' => $this->files->has('poster') ? $this->moveFile($this->files->get('poster'), '/image/products/', 'poster') : $this->product->profile->image]);
}
示例2: update
/**
* Update the specified product in storage.
*
* @param ProductRequest $request
* @param Product $product
* @return Response
*
*/
public function update(ProductRequest $request, Product $product)
{
$this->data = $product->update($request->all());
return $this->handleRedirect($request);
}