app/Http/Controllers/ProductoController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(ProductoRequest $request)
    {
      $direccion=Storage::disk('public')->put('imagenes',$request->file('imagen'));
        try{
          $producto=new Producto($request->all());
          $producto->stock=0;
          $producto->fill(['imagen'=>asset($direccion)])->save();
          return redirect()->action('ProductoController@index',['producto' =>$producto->id])->with('msj','Producto agregado con éxito');
        }catch(Exception $e)
          {
        }
    }
public function store ( ProductoRequest $ request ) { $ direccion = Storage :: disk ( 'public' ) -> put ( 'imagenes' , $ request -> file ( 'imagen' ) ) ; try { $ producto = new Producto ( $ request -> all ( ) ) ; $ producto -> stock = 0 ; $ producto -> fill ( [ 'imagen' => asset ( $ direccion ) ] ) -> save ( ) ; return redirect ( ) -> action ( 'ProductoController@index' , [ 'producto' => $ producto -> id ] ) -> with ( 'msj' , 'Producto agregado con éxito') ; } catch ( Exception $ e ) { } }
Store a newly created resource in storage.
Store a newly created resource in storage .