本文整理汇总了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);
}