app/Http/Controllers/ProductController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
    {
        $update_product = Product::find($id);
        $update_product->name_product = $request->update_name_product;
        $update_product->price_product = $request->update_price_product;
        $update_product->discount_price_product = $request->update_discount_price_product;
        $update_product->desc_product = $request->update_desc_product;
        $update_product->id_brand = $request->brand_product;
        $update_product->status_product = $request->update_status_product;
        $update_product->highlight_product = $request->update_highlight_product;
        $update_product->classify_product = $request->update_classify_product;
        $get_img = $request->file('update_img_product');
        if ($get_img) {
            $this->add_image($update_product, $get_img, 'image_product');
        }
        $get_img1 = $request->file('update_detail_1_img_product');
        if ($get_img1) {
            $this->add_image($update_product, $get_img1, 'detail1_image_product');
        }
        $get_img2 = $request->file('update_detail_2_img_product');
        if ($get_img2) {
            $this->add_image($update_product, $get_img2, 'detail2_image_product');
        }
        $get_img3 = $request->file('update_detail_3_img_product');
        if ($get_img3) {
            $this->add_image($update_product, $get_img3, 'detail3_image_product');
        }
        $get_img4 = $request->file('update_detail_4_img_product');
        if ($get_img4) {
            $this->add_image($update_product, $get_img4, 'detail4_image_product');
        }
        $update_product->save();
        Session::put('messge_cnsp', 'Cập nhật sản phẩm ' . $request->update_name_product . ' thành công.');
        return Redirect('/products');
    }
public function update ( Request $ request , $ id ) { $ update_product = Product :: find ( $ id ) ; $ update_product -> name_product = $ request -> update_name_product ; $ update_product -> price_product = $ request -> update_price_product ; $ update_product -> discount_price_product = $ request -> update_discount_price_product ; $ update_product -> desc_product = $ request -> update_desc_product ; $ update_product -> id_brand = $ request -> brand_product ; $ update_product -> status_product = $ request -> update_status_product ; $ update_product -> highlight_product = $ request -> update_highlight_product ; $ update_product -> classify_product = $ request -> update_classify_product ; $ get_img = $ request -> file ( 'update_img_product' ) ; if ( $ get_img ) { $ this -> add_image ( $ update_product , $ get_img , 'image_product' ) ; } $ get_img1 = $ request -> file ( 'update_detail_1_img_product' ) ; if ( $ get_img1 ) { $ this -> add_image ( $ update_product , $ get_img1 , 'detail1_image_product' ) ; } $ get_img2 = $ request -> file ( 'update_detail_2_img_product' ) ; if ( $ get_img2 ) { $ this -> add_image ( $ update_product , $ get_img2 , 'detail2_image_product' ) ; } $ get_img3 = $ request -> file ( 'update_detail_3_img_product' ) ; if ( $ get_img3 ) { $ this -> add_image ( $ update_product , $ get_img3 , 'detail3_image_product' ) ; } $ get_img4 = $ request -> file ( 'update_detail_4_img_product' ) ; if ( $ get_img4 ) { $ this -> add_image ( $ update_product , $ get_img4 , 'detail4_image_product' ) ; } $ update_product -> save ( ) ; Session :: put ( 'messge_cnsp' , 'Cập nhật sản phẩm ' . $requ s - >update _n ame_product . ' thà h công.'); return Redirect ( '/products' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
//Cập nhật hình ảnh sản phẩm //Cập nhật hình ảnh 1 chi tiết sản phẩm //Cập nhật hình ảnh 2 chi tiết sản phẩm //Cập nhật hình ảnh 3 chi tiết sản phẩm //Cập nhật hình ảnh 4 chi tiết sản phẩm