當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Product::fill方法代碼示例

本文整理匯總了PHP中app\models\Product::fill方法的典型用法代碼示例。如果您正苦於以下問題:PHP Product::fill方法的具體用法?PHP Product::fill怎麽用?PHP Product::fill使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\Product的用法示例。


在下文中一共展示了Product::fill方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: store

 public function store(EditProductRequest $request)
 {
     $product = new Product();
     $product->fill($request->only($product->getFillable()));
     $product->save();
     return redirect()->route('product.index')->with('success_message', 'The product has been successfully saved.');
 }
開發者ID:rundef,項目名稱:laravel_backbone,代碼行數:7,代碼來源:ProductController.php

示例2: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(UpdateProductRequest $request, Product $product)
 {
     $data = $request->input();
     $product->fill($data);
     $product->save();
     $this->savePhoto($product, $request);
     $product->categories()->detach($product->categories()->lists('id')->toArray());
     $product->categories()->attach($data['categories']);
     return Redirect()->route('home');
 }
開發者ID:RsanabriaZ,項目名稱:web-catalog,代碼行數:17,代碼來源:ProductController.php

示例3: store

 /**
  * Untuk menyimpan data product
  * 
  * @param  Request $request [description]
  * @return [type]           [description]
  */
 public function store(Request $request, Supplierable $supplier)
 {
     $this->validate($request, ['code' => 'required', 'name' => 'required', 'description' => 'required', 'price' => 'required', 'category_id' => 'required']);
     $data = $request->only('code', 'name', 'description', 'price', 'category_id');
     if (is_string($request->get('tags'))) {
         $tags = explode(',', $request->get('tags'));
     } else {
         $tags = $request->get('tags', []);
     }
     $product = new Product();
     $product->fill($data);
     $product->supplier()->associate($supplier);
     $product->save();
     $this->productRepository->saveTags($product, $tags);
     if ($product) {
         return ['status' => 'success', 'message' => 'Product has successfully added.', 'product' => $product];
     } else {
         return ['status' => 'failed', 'message' => 'Product has failed to be added.'];
     }
 }
開發者ID:amteknologi,項目名稱:e-commerce,代碼行數:26,代碼來源:ProductController.php

示例4: store

 /**
  * Store a newly created resource in storage.
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make(Input::all(), Product::$product_rules);
     if ($validator->passes()) {
         $user = Auth::user();
         $file_rename = $this->renameImage();
         if (Request::file('image')->move(public_path() . '/uploads', $file_rename)) {
             $product_data = new Product();
             $product_data->fill(Input::all());
             $product_data['image'] = $file_rename;
             if ($user->product()->save($product_data)) {
                 Session::flash('message.success', 'Item added successfully.');
                 return Redirect::to("home");
             } else {
                 Session::flash('message.arrayErrors', $validator->messages()->all());
                 return Redirect::to('add-product')->withInput(Input::all());
             }
         }
     } else {
         Session::flash('message.arrayErrors', $validator->messages()->all());
         return Redirect::to('add-product')->withInput(Input::all());
     }
 }
開發者ID:alexandrzavalii,項目名稱:larabid,代碼行數:27,代碼來源:ProductController.php

示例5: update

 /**
  * Update the specified product
  *
  * @param  ProductRequest $request
  * @param  Product        $product
  * @return Response
  */
 public function update(EditProductRequest $request, Product $product)
 {
     $input = $request->except('image');
     $image = $request->file('image');
     if (!isset($input['active'])) {
         $input['active'] = false;
     }
     if (!isset($input['new'])) {
         $input['new'] = false;
     }
     if ($image != null) {
         // Picture name will be same as SKU
         $name = $input['sku'];
         // Extenstion of original picture
         $extension = '.' . $image->getClientOriginalExtension();
         // Set paths for full image and thumbnail
         $imagePath = 'img/' . $name . $extension;
         $thumbnailPath = 'img/thumbs/' . $name . $extension;
         // Save original picture
         \Image::make($image->getRealPath())->save(public_path($imagePath));
         // Save resized thumbnail
         \Image::make($image->getRealPath())->resize(300, null, function ($constraint) {
             $constraint->aspectRatio();
         })->save(public_path($thumbnailPath));
         // Create Product model and save pictures
         $product->fill($input);
         $product->image = $imagePath;
         $product->image_thumb = $thumbnailPath;
         $product->save();
         return redirect(route('AdminProductShow', $product->slug));
     }
     $product->fill($input);
     $product->save();
     return redirect(route('AdminProductShow', $product->slug));
 }
開發者ID:catchup-forks,項目名稱:gameshop,代碼行數:42,代碼來源:ProductController.php


注:本文中的app\models\Product::fill方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。