app/Http/Controllers/ProductController.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(Request $request)
    {
       $product = new Product;
        $product->name = $request->input('name');
        $product->price = $request->input('price');
        $product->status = $request->input('status');
        if($request->hasFile('file')){
            $file = $request->file('file');
            $name = time().$file->getClientOriginalName();
            $file->move(public_path().'/image/',$name);
        }
        $product->file = $name;
        $product->save();
        return redirect()->route('products.index')
            ->with('info','Producto creado con éxito');
    }
public function store ( Request $ request ) { $ product = new Product ; $ product -> name = $ request -> input ( 'name' ) ; $ product -> price = $ request -> input ( 'price' ) ; $ product -> status = $ request -> input ( 'status' ) ; if ( $ request -> hasFile ( 'file' ) ) { $ file = $ request -> file ( 'file' ) ; $ name = time ( ) . $ file -> getClientOriginalName ( ) ; $ file -> move ( public_path ( ) . '/image/' , $ name ) ; } $ product -> file = $ name ; $ product -> save ( ) ; return redirect ( ) -> route ( 'products.index' ) -> with ( 'info' , 'Producto creado con éxito') ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//IMAGE 