Ejemplo n.º 1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(SaveProductRequest $request, Product $product)
 {
     $product->fill($request->all());
     $product->slug = str_slug($request->get('name'));
     $product->visible = $request->has('visible') ? 1 : 0;
     $updated = $product->save();
     $message = $updated ? 'Producto actualizado correctamente!' : 'El Producto NO pudo actualizarse!';
     return redirect()->route('admin.product.index')->with('message', $message);
 }
Ejemplo n.º 2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(SaveProductRequest $request, Product $product)
 {
     $product->fill($request->all());
     $product->slug = str_slug($request->get('name'));
     $product->visible = $request->has('visible') ? 1 : 0;
     $updated = $product->save();
     $message = $updated ? 'Product was updated successfully!' : 'Could not update product!';
     return redirect()->route('admin.product.index')->with('message', $message);
 }
Ejemplo n.º 3
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(SaveProductRequest $request)
 {
     $data = ['name' => $request->get('name'), 'slug' => str_slug($request->get('name')), 'description' => $request->get('description'), 'extract' => $request->get('extract'), 'price' => $request->get('price'), 'price_bf' => $request->get('price_bf'), 'visible' => $request->has('visible') ? 1 : 0, 'category_id' => $request->get('category_id')];
     $product = Product::create($data);
     $imageName = $product->slug . '.' . $request->file('image')->getClientOriginalExtension();
     $request->file('image')->move(base_path() . '/public/img/productos-img/', $imageName);
     $product->image = $imageName;
     $product->save();
     $message = $product ? 'Producto agregado correctamente!' : 'El producto NO pudo agregarse!';
     return redirect()->route('admin.product.index')->with('message', $message);
 }