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)
    {
        $add_product = new Product();
        $add_product->name_product = $request->add_name_product;
        $add_product->slug_product = Str::slug($request->add_name_product, '-') . '-' . Carbon::now('Asia/Ho_Chi_Minh')->timestamp;
        $add_product->price_product = $request->add_price_product;
        $add_product->discount_price_product = $request->add_discount_price_product;
        $add_product->desc_product = $request->add_desc_product;
        $add_product->content_product = $request->add_content_product;
        $add_product->id_brand = $request->brand_product;
        $add_product->status_product = $request->product_status;
        $add_product->classify_product = $request->product_classify;
        $add_product->highlight_product = $request->add_highlight_product;
        $get_img = $request->file('add_img_product');
        if ($get_img) {
            $this->add_image($add_product, $get_img, 'image_product');
        }
        $get_img1 = $request->file('add_detail_1_img_product');
        if ($get_img1) {
            $this->add_image($add_product, $get_img1, 'detail1_image_product');
        }
        $get_img2 = $request->file('add_detail_2_img_product');
        if ($get_img2) {
            $this->add_image($add_product, $get_img2, 'detail2_image_product');
        }
        $get_img3 = $request->file('add_detail_3_img_product');
        if ($get_img3) {
            $this->add_image($add_product, $get_img3, 'detail3_image_product');
        }
        $get_img4 = $request->file('add_detail_4_img_product');
        if ($get_img4) {
            $this->add_image($add_product, $get_img4, 'detail4_image_product');
        }
        $add_product->save();
        Session::put('messge_sp', 'Thêm sản phẩm ' . $request->add_name_product . ' thành công.');
        return Redirect('/products');
    }
public function store ( Request $ request ) { $ add_product = new Product ( ) ; $ add_product -> name_product = $ request -> add_name_product ; $ add_product -> slug_product = Str :: slug ( $ request -> add_name_product , '-' ) . '-' . Carbon :: now ( 'Asia/Ho_Chi_Minh' ) -> timestamp ; $ add_product -> price_product = $ request -> add_price_product ; $ add_product -> discount_price_product = $ request -> add_discount_price_product ; $ add_product -> desc_product = $ request -> add_desc_product ; $ add_product -> content_product = $ request -> add_content_product ; $ add_product -> id_brand = $ request -> brand_product ; $ add_product -> status_product = $ request -> product_status ; $ add_product -> classify_product = $ request -> product_classify ; $ add_product -> highlight_product = $ request -> add_highlight_product ; $ get_img = $ request -> file ( 'add_img_product' ) ; if ( $ get_img ) { $ this -> add_image ( $ add_product , $ get_img , 'image_product' ) ; } $ get_img1 = $ request -> file ( 'add_detail_1_img_product' ) ; if ( $ get_img1 ) { $ this -> add_image ( $ add_product , $ get_img1 , 'detail1_image_product' ) ; } $ get_img2 = $ request -> file ( 'add_detail_2_img_product' ) ; if ( $ get_img2 ) { $ this -> add_image ( $ add_product , $ get_img2 , 'detail2_image_product' ) ; } $ get_img3 = $ request -> file ( 'add_detail_3_img_product' ) ; if ( $ get_img3 ) { $ this -> add_image ( $ add_product , $ get_img3 , 'detail3_image_product' ) ; } $ get_img4 = $ request -> file ( 'add_detail_4_img_product' ) ; if ( $ get_img4 ) { $ this -> add_image ( $ add_product , $ get_img4 , 'detail4_image_product' ) ; } $ add_product -> save ( ) ; Session :: put ( 'messge_sp' , 'Thêm sản phẩm ' . $r q e st->add _n ame_product . '  h nh công.'); return Redirect ( '/products' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//Thêm hình ảnh sản phẩm //Thêm hình ảnh 1 chi tiết sản phẩm //Thêm hình ảnh 2 chi tiết sản phẩm //Thêm hình ảnh 3 chi tiết sản phẩm //Thêm hình ảnh 4 chi tiết sản phẩm