当前位置: 首页>>代码示例>>PHP>>正文


PHP Product::update方法代码示例

本文整理汇总了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();
 }
开发者ID:emadmrz,项目名称:Hawk,代码行数:8,代码来源:CommentController.php

示例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');
     }
 }
开发者ID:ifaniqbal,项目名称:medium,代码行数:13,代码来源:ProductController.php

示例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());
 }
开发者ID:polytechlyon-isi2,项目名称:AgnamStore,代码行数:20,代码来源:ProductTrait.php

示例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));
 }
开发者ID:Tisho84,项目名称:laravel-work,代码行数:16,代码来源:OrderProductsController.php

示例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!');
 }
开发者ID:Tisho84,项目名称:laravel-work,代码行数:11,代码来源:ProductsController.php

示例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' => '产品更新失败, 请重试']);
 }
开发者ID:CaliProject,项目名称:mikenong-dev,代码行数:13,代码来源:ManageController.php

示例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);
 }
开发者ID:nasikgiga,项目名称:onlineshop,代码行数:19,代码来源:ProductController.php

示例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');
 }
开发者ID:ronipl,项目名称:gs3-web-app,代码行数:15,代码来源:ProductsController.php

示例9: update

 function update(Product $product, CreateProductRequest $request)
 {
     $product->update($request->all());
     return redirect('products');
 }
开发者ID:BrunoQuaresma,项目名称:tutorials,代码行数:5,代码来源:ProductsController.php

示例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);
 }
开发者ID:hieunt88,项目名称:laravel-catalog,代码行数:13,代码来源:ProductsController.php

示例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));
 }
开发者ID:maherelgamil,项目名称:ketabat,代码行数:10,代码来源:ProductsController.php

示例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');
     }
 }
开发者ID:rereyossi,项目名称:hairstuation,代码行数:37,代码来源:ProductController.php

示例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'));
 }
开发者ID:SpencerRohan,项目名称:tutorial-2,代码行数:13,代码来源:Products.php

示例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!");
 }
开发者ID:Yismen,项目名称:solpieles,代码行数:12,代码来源:ProductsController.php

示例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();
 }
开发者ID:emadmrz,项目名称:Hawk,代码行数:13,代码来源:ProductController.php


注:本文中的app\Product::update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。