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['productname'];
        $product->brandid = $request['brandid'];
        $product->cost = $request['cost'];
        $product->promocost = $request['promocost'];
        $product->bookingamount = $request['bookingamount'];
        $product->installamt = $request['installamt'];
        $product->longdescription = $request['fulldescription'];
        $product->shortdescription = $request['shortdescription'];
        $product->cashback_by_type = $request['cashback_by_type'];
        $product->cashback_value = $request['cashback_value'];
        $rarefile = $request->file('image1');    
        if($rarefile!=''){
        $raupload = public_path() .'/img/productimage/';
        $rarefilename=time().'.'.$rarefile->getClientOriginalName();
        $success=$rarefile->move($raupload,$rarefilename);
        $product->image1 = $rarefilename;
            }
             $image2 = $request->file('image2');    
        if($image2!=''){
        $raupload = public_path() .'/img/productimage/';
        $image2name=time().'.'.$image2->getClientOriginalName();
        $success=$image2->move($raupload,$image2name);
        $product->image2 = $image2name;
            }
         $image3 = $request->file('image3');    
        if($image3!=''){
        $raupload = public_path() .'/img/productimage/';
        $image3name=time().'.'.$image3->getClientOriginalName();
        $success=$image3->move($raupload,$image3name);
        $product->image3 = $image3name;
            }
         $image4 = $request->file('image4');    
    if($image4!=''){
    $raupload = public_path() .'/img/productimage/';
    $image4name=time().'.'.$image4->getClientOriginalName();
    $success=$image4->move($raupload,$image4name);
    $product->image4 = $image4name;
        }
        $product->save();
    return back();
    }
public function store ( Request $ request ) { $ product = new product ( ) ; $ product -> name = $ request [ 'productname' ] ; $ product -> brandid = $ request [ 'brandid' ] ; $ product -> cost = $ request [ 'cost' ] ; $ product -> promocost = $ request [ 'promocost' ] ; $ product -> bookingamount = $ request [ 'bookingamount' ] ; $ product -> installamt = $ request [ 'installamt' ] ; $ product -> longdescription = $ request [ 'fulldescription' ] ; $ product -> shortdescription = $ request [ 'shortdescription' ] ; $ product -> cashback_by_type = $ request [ 'cashback_by_type' ] ; $ product -> cashback_value = $ request [ 'cashback_value' ] ; $ rarefile = $ request -> file ( 'image1' ) ; if ( $ rarefile != '' ) { $ raupload = public_path ( ) . '/img/productimage/' ; $ rarefilename = time ( ) . '.' . $ rarefile -> getClientOriginalName ( ) ; $ success = $ rarefile -> move ( $ raupload , $ rarefilename ) ; $ product -> image1 = $ rarefilename ; } $ image2 = $ request -> file ( 'image2' ) ; if ( $ image2 != '' ) { $ raupload = public_path ( ) . '/img/productimage/' ; $ image2name = time ( ) . '.' . $ image2 -> getClientOriginalName ( ) ; $ success = $ image2 -> move ( $ raupload , $ image2name ) ; $ product -> image2 = $ image2name ; } $ image3 = $ request -> file ( 'image3' ) ; if ( $ image3 != '' ) { $ raupload = public_path ( ) . '/img/productimage/' ; $ image3name = time ( ) . '.' . $ image3 -> getClientOriginalName ( ) ; $ success = $ image3 -> move ( $ raupload , $ image3name ) ; $ product -> image3 = $ image3name ; } $ image4 = $ request -> file ( 'image4' ) ; if ( $ image4 != '' ) { $ raupload = public_path ( ) . '/img/productimage/' ; $ image4name = time ( ) . '.' . $ image4 -> getClientOriginalName ( ) ; $ success = $ image4 -> move ( $ raupload , $ image4name ) ; $ product -> image4 = $ image4name ; } $ product -> save ( ) ; return back ( ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .