Ejemplo n.º 1
2
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(ProductRequest $request)
 {
     //
     $data = $request->all();
     if (isset($data['image'])) {
         $thumb = $data['image'];
         $new = 'pro' . uniqid() . '.' . $thumb->getClientOriginalExtension();
         $thumb->move('upload/product', $new);
     }
     $data['image'] = $new;
     $productId = Product::addProduct($data);
     $multi_image = Input::file('multi-images');
     foreach ($multi_image as $multi) {
         # code...
         $thumbnail = 'multi' . uniqid() . '.' . $multi->getClientOriginalExtension();
         $multi->move('upload/multi-image', $thumbnail);
         Image::addImage($productId, $thumbnail);
     }
     if (Input::get('color') != "") {
         $color = Input::get('color');
         foreach ($color as $colorId) {
             # code...
             MapColor::mapColor($colorId, $productId);
         }
     }
     if ($data['other_color'] != "") {
         $other = $data['other_color'];
         $colorId = Color::addColor($other);
         MapColor::mapColor($colorId, $productId);
     }
     if (Input::get('size') != "") {
         $size = Input::get('size');
         foreach ($size as $sizeId) {
             # code...
             MapSize::mapSize($sizeId, $productId);
         }
     }
     if ($data['other_size'] != "") {
         $other = $data['other_size'];
         $sizeId = Size::addSize($other);
         MapSize::mapsize($sizeId, $productId);
     }
     return redirect('admin/product');
     //return "ok";
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(ProductRequest $request)
 {
     $product = Product::create($request->all());
     // get code
     //$code = date('Ymd') . date("hi");
     $code = date('md') . date("hi");
     $product->code = $code;
     // get arvatar 4 product
     $product->avatar = $this->_getAvatar($product->gallery);
     //set more info before save data
     $this->setDefaultInfoBeforeSave($product, true);
     $blnProduct = $product->save();
     $blnProductI10n = false;
     if ($blnProduct) {
         $productI10N = Product_I10N::create($request->all());
         $productI10N->i18n_id = $product->id;
         // name
         $productI10N->name = $productI10N->name . ' ' . $code;
         //$productI10N->price = $productI10N-> . $code;
         //set more info before save data
         $this->setDefaultInfoBeforeSave($productI10N, true);
         $blnProductI10n = $productI10N->save();
     }
     //result
     if ($blnProduct && $blnProductI10n) {
         return Redirect::route('admin.product.edit', $product->id)->with('message', new MessageBag(['save_complete']));
     } else {
         return Redirect::route('admin.product.create', $product)->with('message', new MessageBag(['save_error']));
     }
 }
Ejemplo n.º 3
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(\App\Http\Requests\ProductRequest $request, $id)
 {
     $product = $this->products->find($id);
     $product->update($request->all(), $product->id);
     \Session::flash('update_message', 'Your product has been updated');
     return redirect('products');
 }
Ejemplo n.º 4
0
 /**
  * Update the specified resource in storage.
  *
  * @param ProductRequest $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(ProductRequest $request, $id)
 {
     $input = $request->all();
     $input['type'] = 'Product';
     Item::find($id)->update($input);
     return redirect()->route('product.index')->withMessage('Product has been Updated')->withStatus('success');
 }
Ejemplo n.º 5
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @param Request $request
  * @return Response
  */
 public function update(ProductRequest $request, $id)
 {
     $inputData = $request->all();
     $product = Product::findOrFail($id);
     $product->updateProduct($inputData);
     return redirect()->action('Admin\\ProductController@index')->with('message', 'Item updated successfully.');
 }
Ejemplo n.º 6
0
 /**
  * @param ProductRequest $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function product_create(ProductRequest $request)
 {
     //        product::create(Request::all());
     //
     product::create($request->all());
     return redirect('add-product');
 }
Ejemplo n.º 7
0
 /**
  * Store a newly created Product in database.
  *
  * @return Response
  */
 public function store(ProductRequest $request)
 {
     /**
      * Take all inputs except image, store image in seperate variable
      *
      * @var Array
      */
     $input = $request->except('image');
     $image = $request->file('image');
     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));
     } else {
         // Set default 'No image avaliable' images
         $imagePath = self::DEFAULT_IMG;
         $thumbnailPath = self::DEFAULT_IMG;
     }
     // Create Product model and save pictures
     $product = Product::create($input);
     $product->image = $imagePath;
     $product->image_thumb = $thumbnailPath;
     $product->save();
     return redirect(route('AdminProductIndex'));
 }
 public function postAdd(ProductRequest $request_product)
 {
     $product = new Product();
     $file_name = $request_product->file('fileimages')->getClientOriginalName();
     $product->name = $request_product->txtten;
     $product->alias = str_slug($request_product->txtten);
     $product->price = $request_product->txtgia;
     $product->pricesale = $request_product->txtgiasale;
     $product->intro = $request_product->txtndhienthi;
     $product->content = $request_product->txtndchitiet;
     $product->image = $file_name;
     $product->keywork = $request_product->txtkeyword;
     $product->discription = $request_product->txtmota;
     $product->user_id = Auth::user()->id;
     $product->cate_id = $request_product->parentid;
     $request_product->file('fileimages')->move('public/upload/', $file_name);
     $product->save();
     $product_id = $product->id;
     if (Input::hasFile('fileimageschitiet')) {
         foreach (Input::file('fileimageschitiet') as $file) {
             $product_img = new ProductImage();
             if (isset($file)) {
                 $product_img->image = $file->getClientOriginalName();
                 $product_img->product_id = $product_id;
                 $file->move('public/upload/images_detail/', $file->getClientOriginalName());
                 $product_img->save();
             }
         }
     }
     return redirect()->route('admin.product.getList')->with(['flash_level' => 'success', 'flash_message' => 'Thêm sản phẩm thành công']);
 }
Ejemplo n.º 9
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  * @return Response
  */
 public function update(ProductRequest $request, $id)
 {
     $product = Product::findOrFail($id);
     $input = $request->all();
     $product->update($input);
     return redirect('product/' . $id);
 }
 /**
  * Guarda un nuevo record en nuestra tabla de products
  *
  * @param  ProductRequest  $request -> valida los campos requeridos para crear un nuevo producto
  * @return \Illuminate\Http\Response
  */
 public function store(ProductRequest $request)
 {
     /* creaco una nuevo producto */
     /* $request->all() trae la formación que se ingreso en la forma */
     Product::create($request->all());
     /* redirege a el listado de productos */
     return redirect('products');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(ProductRequest $request)
 {
     $product = Product::create($request->all());
     $thumb = $request->file('thumb');
     $banner = $request->file('banner');
     $product->saveThumbs($thumb, $banner);
     $product->save();
     return redirect('/admin/products');
 }
Ejemplo n.º 12
0
 /**
  * Update the specified resource in storage.
  *
  * @param ProductRequest $request
  * @param Product $product
  * @return mixed
  */
 public function update(ProductRequest $request, Product $product)
 {
     //dd($request->all());
     $product->update($request->all());
     if ($product) {
         Flash::success('修改成功!');
         return Redirect::to('/admin/product/' . $product->id . '/edit');
     } else {
         Flash::error('修改失败!');
         return Redirect::back()->withInput();
     }
 }
Ejemplo n.º 13
0
 /**
  * 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);
 }
 public function productedit(ProductRequest $request)
 {
     $imageName = date('\\YY\\Mm\\Dd\\THi') . str_random(3) . str_random(4) . '.' . $request->file('image')->getClientOriginalExtension();
     $request->file('image')->move(public_path() . '/uploads/', $imageName);
     $product = Products(array('name' => $request->get('name'), 'brand_id' => $request->get('brand_id'), 'hot' => $request->get('hot'), 'price' => $request->get('price'), 'description' => $request->get('description'), 'image' => url('uploads/' . $imageName)));
     $product->save();
     return \Redirect::route('products');
 }
Ejemplo n.º 15
0
 /**
  * @param Requests\ProductRequest $request
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update(ProductRequest $request, $id)
 {
     $product = Product::find($id);
     $tags = !empty($request->input('tag_id')) ? $request->input('tag_id') : [];
     $product->tags()->sync($tags);
     if ($request->input('deletePicture') == 'true') {
         $deletePicture = $this->deletePicture($product);
     }
     $im = $request->file('picture');
     if (!is_null($im)) {
         if (empty($deletePicture)) {
             $this->deletePicture($product);
         }
         $this->upload($im, $product->id);
     }
     $product->update($request->all());
     return redirect('product')->with(['message' => 'success update']);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Requests\ProductRequest $request, $id)
 {
     $monProduit = Product::find($id);
     $monProduit->update($request->all());
     $tags = $request->input('tags');
     $monProduit->tags()->detach();
     $monProduit->tags()->attach($tags);
     Upload::image($request, $monProduit);
     return redirect('/product')->with(['message' => 'Mise à jour réalisée avec succès']);
 }
Ejemplo n.º 17
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create(Requests\ProductRequest $request)
 {
     $user = \Auth::user();
     $productType = 2;
     $project = new Project();
     $project->creator = $user->id;
     $project->feedback_types_id = $productType;
     $project->name = $request->name;
     $project->description = $request->description;
     $myStr = str_random(10);
     $imageName = $request->name . '_' . $myStr . '_' . $user->id . '.' . $request->file('photo')->getClientOriginalExtension();
     $imageName = $string = str_replace(' ', '', $imageName);
     $imagePath = '/upload/images/' . $imageName;
     $request->file('photo')->move(base_path() . '/public/upload/images/', $imageName);
     $project->photo = $imagePath;
     if ($project->save()) {
         return redirect('vendor/my-projects');
     }
 }
Ejemplo n.º 18
0
 public function update($id, ProductRequest $request)
 {
     $product = Product::findOrFail($id);
     if ($request->file('image')) {
         if ($product->image) {
             $old_image = public_path('product/images/' . $product['image']);
             File::delete($old_image);
         }
         $product->update($request->all());
         $new_image = $request->file('image');
         $filename = $product->id . time() . '.' . $new_image->getClientOriginalExtension();
         $path = public_path('product/images/' . $filename);
         $product->update(['image' => $filename]);
         Image::make($new_image->getRealPath())->widen(100, function ($constraint) {
             $constraint->upsize();
         })->save($path);
     } else {
         $product->update($request->all());
     }
     return redirect('products');
 }
 public function store(Requests\ProductRequest $request)
 {
     if ($request->hasFile('photo')) {
         $photoName = $request->file('photo')->getClientOriginalName();
         $request->file('photo')->move(public_path() . '/uploads', $photoName);
         $data = $request->all();
         $data['photoName'] = '/uploads/' . $photoName;
         $request->replace($data);
     }
     $this->productRep->store($request->all(), $request->categories);
     return redirect('/product');
 }
Ejemplo n.º 20
0
 /**
  * Update Product.
  *
  * @param ProductRequest $request
  *
  * @return Response
  *
  */
 public function update(ProductRequest $request, $id)
 {
     $product = Product::findOrFail($id);
     $data = $request->all();
     $uploadFile = $request->file('image');
     $imageName = sprintf('%s-%s', $product->id, $uploadFile->getClientOriginalName());
     $filePath = base_path() . '/public/images/catalog/';
     if (!file_exists($filePath . $imageName)) {
         $request->file('image')->move($filePath, $imageName);
     }
     $data['image'] = $imageName;
     $product->update($data);
     flash('Product Updated');
     return redirect('/admin/products');
 }
Ejemplo n.º 21
0
 public function update($id, ProductRequest $request)
 {
     $product = Product::findOrFail($id);
     if ($request->has('is_locked')) {
         $product->is_locked = 1;
     } else {
         $product->is_locked = 0;
     }
     if ($request->hasFile('image_name')) {
         $imageName = $product->id . '.' . $request->file('image_name')->getClientOriginalExtension();
         $request->file('image_name')->move('images', $imageName);
         $product->image_name = $imageName;
     }
     $product->update($request->all());
     return redirect('products');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(ProductRequest $request, $id)
 {
     $product = Product::find($id);
     $product->name = $request->name;
     $product->price = $request->price;
     $product->description = $request->description;
     $product->category_id = $request->category_id;
     $product->resluggify();
     $product->save();
     //Upload file
     if ($request->hasFile('file')) {
         $files = $request->file('file');
         foreach ($files as $file) {
             $rules = array('file' => 'mimes:png,jpeg,jpg');
             //'required|mimes:png,gif,jpeg,txt,pdf,doc'
             $validator = Validator::make(array('file' => $file), $rules);
             if ($validator->passes()) {
                 $destinationPath = 'uploads';
                 $filename = time() . '-' . $file->getClientOriginalName();
                 $path = $destinationPath . '/' . $filename;
                 $success = $file->move($destinationPath, $filename);
                 if ($success) {
                     $thumbPath = 'uploads/thumbs/';
                     $thumb1 = Image::make($path)->resize(270, 180)->save($thumbPath . $filename);
                     $photo = new Photo();
                     $photo->title = $filename;
                     $photo->product_id = $id;
                     $photo->save();
                 }
             }
         }
     }
     return redirect()->route('admin.product.edit', $product->slug);
 }
Ejemplo n.º 23
0
 public function ProductPostEdit(ProductRequest $request, $id)
 {
     $name = $request->get("name");
     $alias = str_slug($name);
     $cate = $request->get("cate");
     $brand = $request->get("brand");
     $price = $request->get("price");
     $size = $request->get("size");
     $img = $request->file("img");
     //new img
     $currentImg = $request->get("currentImg");
     //current img
     $imgDel = $request->get("imgDel");
     //img del
     $detail = $request->get("detail");
     $status = $request->get("status");
     /** Luu thong tin hinh cu**/
     $img1 = "";
     $img2 = "";
     $img3 = "";
     $img4 = "";
     if (isset($currentImg[0])) {
         $img1 = $currentImg[0];
     }
     if (isset($currentImg[1])) {
         $img2 = $currentImg[1];
     }
     if (isset($currentImg[2])) {
         $img3 = $currentImg[2];
     }
     if (isset($currentImg[3])) {
         $img4 = $currentImg[3];
     }
     /****Them hinh moi****/
     for ($i = 1; $i <= count($img); $i++) {
         switch ($i) {
             case 1:
                 if (!is_null($img[$i - 1])) {
                     $img1 = date("jnyGis") . $img[$i - 1]->getClientOriginalName();
                     $img[$i - 1]->move("public/products/", $img1);
                 }
                 break;
             case 2:
                 if (!is_null($img[$i - 1])) {
                     $img2 = date("jnyGis") . $img[$i - 1]->getClientOriginalName();
                     $img[$i - 1]->move("public/products", $img2);
                 }
                 break;
             case 3:
                 if (!is_null($img[$i - 1])) {
                     $img3 = date("jnyGis") . $img[$i - 1]->getClientOriginalName();
                     $img[$i - 1]->move("public/products", $img3);
                 }
                 break;
             case 4:
                 if (!is_null($img[$i - 1])) {
                     $img4 = date("jnyGis") . $img[$i - 1]->getClientOriginalName();
                     $img[$i - 1]->move("public/products", $img4);
                 }
                 break;
         }
     }
     /**Xoa hinh cu**/
     $this->deleteImage($imgDel);
     /***************/
     $product = Products::find($id);
     $product->name = $name;
     $product->alias = $alias;
     $product->cate_id = $cate;
     $product->brand = $brand;
     $product->description = $detail;
     $product->price = $price;
     $product->size = $size;
     $product->status = $status;
     $product->img1 = $img1;
     $product->img2 = $img2;
     $product->img3 = $img3;
     $product->img4 = $img4;
     $result = $product->save();
     if ($result) {
         $result = "Cập nhật sản phẩm thành công";
     } else {
         $result = "Chưa cập nhật được";
     }
     return redirect()->route("admin.product.list")->with("result", $result);
 }
Ejemplo n.º 24
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(ProductRequest $request, $id)
 {
     $product = Product::findOrFail($id);
     $product->update($request->all());
     $this->saveExtraProductRequest($product, $request->all());
     $categorys = (array) $request->input('category_list');
     $this->syncCategorys($product, $categorys);
     flash('Product has been updated');
     Product::reindex();
     return Redirect::back();
 }
Ejemplo n.º 25
0
 /**
  * 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)
 {
     $product->name = $request->input('name');
     $product->description = $request->input('description');
     $product->subcategory_id = $request->input('subcategory_id');
     $product->price = $request->input('price');
     $product->save();
     return redirect()->route('products.show', $product->slug);
 }
Ejemplo n.º 26
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Requests\ProductRequest $request, $id)
 {
     $tags = $request->input('tags');
     $product = Product::find($id);
     if (!empty($tags)) {
         //            $product->tags()->detach();
         //            $product->tags()->attach($tags);
         // equivalent à
         $product->tags()->sync($tags);
     } else {
         $product->tags()->detach();
         // s'il n y a pas de tags ou tags décochés
     }
     // gestion image et
     $picture = $product->picture;
     if ($request->input('delete_img') == 1) {
         if (!is_null($picture)) {
             Storage::delete($picture->uri);
             // supprime le fichier physiquement
             $picture->delete();
             // supprime la picture en BDD dans la table pictures
         }
     }
     if (!is_null($request->file('thumbnail'))) {
         // on remet ce bout de code ci-dessous au cas ou boutton supprimer non coché et nouvelle image uploadée
         if (!is_null($picture)) {
             Storage::delete($picture->uri);
             // supprime le fichier physiquement
             $picture->delete();
             // supprime la picture en BDD dans la table pictures
         }
         $im = $request->file('thumbnail');
         // extension de l'image
         $ext = $im->getClientOriginalExtension();
         $uri = str_random(12) . '.' . $ext;
         //        dd($im->move(env('UPLOAD_PATH', './uploads'), $uri));
         $im->move(env('UPLOAD_PATH', './uploads'), $uri);
         // Exception renvoyée par le framework si problem
         # Bien veiller aux fillables de Picture pour que ça marche ci-dessous
         # et !! si on a deja 'move' notre image, getSize ne marche plus, il faut getClientSize
         Picture::create(['uri' => $uri, 'size' => $im->getClientSize(), 'type' => $ext, 'product_id' => $product->id]);
     }
     $product->update($request->all());
     return redirect('product')->with(['alert' => 'done', 'message' => 'update produit']);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(ProductRequest $product_request, $id)
 {
     $product = Product::find($id);
     $product->product_name = $product_request->name;
     $product->cate_id = $product_request->cate_id;
     $product->brand_id = $product_request->brand_id;
     $product->qty = $product_request->qty;
     $product->price = $product_request->price;
     $product->discount = $product_request->discount;
     $product->description = $product_request->description;
     $product->show = $product_request->show;
     $product->feature = $product_request->feature;
     $product->slug = $product_request->slug;
     if ($product_request->file('illustration')) {
         $file_name = $product_request->file('illustration')->getClientOriginalName();
         if ($product->image_name != $file_name) {
             File::delete(public_path() . '/upload/' . $product->image_name);
             $product->image_name = $file_name;
             $product_request->file('illustration')->move('upload', $file_name);
         }
     }
     $product->save();
     $product->size()->sync($product_request->size);
     $product->color()->sync($product_request->color);
     $product_id = $product->id;
     if (Input::file('images')[0] != null) {
         foreach (Input::file('images') as $file) {
             $data = $file->getClientOriginalName();
             $image = new Image();
             $image->image_name = $data;
             $image->product_id = $product_id;
             $file->move('upload/images', $data);
             $image->save();
         }
     }
     return redirect()->route('admin.product.index')->with('message', 'Edit complete');
 }
Ejemplo n.º 28
0
 /**
  * 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!');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(ProductRequest $request, $id)
 {
     $postData = $request->all();
     //获取请求过来的数据
     $this->product->update($id, $postData);
     //使用仓库方法存储
     return redirect()->route('admin.product.index')->with('message', '修改产品成功!');
 }
Ejemplo n.º 30
0
 /**
  * get tag
  */
 public function listTags(ProductRequest $request)
 {
     $key = $request->get('key');
     $tags = Tag::search($key);
     return view('admin.product.list-tags', array('tags' => $tags));
 }