本文整理汇总了PHP中app\Product::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::update方法的具体用法?PHP Product::update怎么用?PHP Product::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Product
的用法示例。
在下文中一共展示了Product::update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: product
public function product(Shop $shop, Product $product, Request $request)
{
$user = Auth::user();
$product->comments()->create(['user_id' => $user->id, 'body' => $request->input('body')]);
$product->update(['num_comment' => $product->comments()->count()]);
Flash::success('comment Added');
return redirect()->back();
}
示例2: edit
public function edit(Request $request, Product $product)
{
if ($request->isMethod('get')) {
// menampilkan form
return view('product.create', compact('product'));
} else {
// save ke db
$this->validate($request, $this->rules);
$input = $request->only('name', 'purchase_price', 'sell_price');
$product->update($input);
return redirect('product');
}
}
示例3: saveProduct
private function saveProduct(Request $request, Product $product)
{
$validator = Product::validate($request->all());
if ($validator->fails()) {
return redirect(route(Route::currentRouteName()))->withErrors($validator->errors());
} else {
if (!is_null($product->id)) {
$product->update($request->all());
Session::flash('success', "Le produit a bien été mis à jour.");
} else {
$product->fill($request->all());
$product->save();
Session::flash('success', "Le produit a bien été crée.");
}
}
if ($param = Route::current()->getParameter('id')) {
return redirect()->route(Route::currentRouteName(), $param);
}
return redirect()->route(Route::currentRouteName());
}
示例4: destroy
/**
* Remove the specified resource from storage.
* order product
* @param int $id
* @return Response
*/
public function destroy(Order $order, Product $product)
{
DB::transaction(function () use($product, $order) {
if ($order->status != 1) {
$product->update(['quantity' => $product->quantity + $order->products()->find($product->id)->pivot->quantity]);
}
$order->products()->detach($product->id);
});
return redirect(route('orders.edit', $order->id));
}
示例5: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update(Product $product, ProductRequest $request)
{
$product->update($request->all());
return redirect('products')->with('success', 'Product updated!');
}
示例6: updateProduct
/**
* Update a product with a POST request
*
* @param CreateProductRequest $request
* @param Product $product
* @return \Illuminate\Http\RedirectResponse
*/
public function updateProduct(CreateProductRequest $request, Product $product)
{
$product->update($request->except(['_token', 'editorValue']));
$product->description = $request->input("editorValue");
return $product->save() ? redirect()->back()->with(['status' => 'success', 'message' => '产品更新成功']) : redirect()->back()->with(['status' => 'error', 'message' => '产品更新失败, 请重试']);
}
示例7: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(ProductRequest $request, Product $product)
{
$data = $request->all();
if ($request->hasFile('img')) {
$file = $request->file('img');
$fileName = time() . '-' . $file->getClientOriginalName();
$file->move('uploads', $fileName);
$data['image'] = $fileName;
}
$product->update($data);
return redirect('product/' . $product->id);
}
示例8: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Product $product, CreateProductRequest $request)
{
$data = $request->all();
$data['other_list'] = $this->arrayStr($data['other_list']);
$data['standard_features'] = $this->arrayStr($data['standard_features']);
$product->update($data);
return redirect('products');
}
示例9: update
function update(Product $product, CreateProductRequest $request)
{
$product->update($request->all());
return redirect('products');
}
示例10: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(ProductRequest $request, Product $product)
{
//
$product->update($request->all());
return redirect('products/' . $product->id);
}
示例11: updateProduct
/**
* Update a product.
*
* @param ProductRequest $request
*/
private function updateProduct(ProductRequest $request, Product $product)
{
$product->update($request->all());
$product->attributes()->sync($this->syncArray($request));
}
示例12: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request, $id = null)
{
$validator = Validator::make($request->all(), ['product_name' => 'required', 'price' => 'required']);
if ($validator->fails()) {
if (!empty($id)) {
return Redirect::to('product/create/' . $id)->withErrors($validator)->withInput();
} else {
return Redirect::to('product/create')->withErrors($validator)->withInput();
}
} else {
if (!empty($id)) {
$product = Product::find($id);
} else {
$product = new Product();
}
$product->product_name = Input::get('product_name');
$product->color = Input::get('color');
$product->desc = Input::get('desc');
$product->price = Input::get('price');
$product->category = Input::get('category');
if (empty($id)) {
$product->rating = 1;
$product->save();
$last_id = $product->id;
} else {
$product->update();
$last_id = $id;
}
return redirect('product/create/' . $last_id)->with('message', 'You have done successfully');
}
}
示例13: update
/**
* Update the specified resource in storage.
*
* @param UpdateProductRequest $request
* @param Product $product
* @return \Illuminate\Http\Response
*/
public function update(UpdateProductRequest $request, Product $product)
{
$product->update($request->all());
$this->message->flash("PUNY HUMAN - Your Product has been updated!");
return redirect()->route('backend.products.show', compact('product'));
}
示例14: update
/**
* save the updates for current product
* @param Product $product
* @param Request $request
* @return [type]
*/
public function update(Product $product, Request $request)
{
$this->validate($request, ['name' => 'required|min:5|max:120', 'short_name' => 'required|min:5|max:80', 'description' => 'required|min:5|max:5000', 'specs' => 'required|min:5|max:5000', 'lang' => 'required']);
$product->update($request->all());
return redirect()->route('admin.products.show', $product->slug)->withSuccess("Product {$product->name} has been updated!");
}
示例15: adminChange
public function adminChange(User $user, Shop $shop, Product $product)
{
if ($product->active == 0) {
//the product is already disabled
$product->update(['active' => 1]);
Flash::success(trans('admin/messages.productActivate'));
} elseif ($product->active == 1) {
//the product is already enabled
$product->update(['active' => 0]);
Flash::success(trans('admin/messages.productBan'));
}
return redirect()->back();
}