app/Http/Controllers/ProductController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Product  $product
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Product $product)
    {
        $data=request()->validate([
            'product_name'=>'required',
            'product_short_description'=>'required',
            'product_code'=>'required',
            'product_description'=>'required',
            'product_features'=>'required',
            'product_category'=>'required',
            'tags'=>'required',
            'product_image'=>'required',
        ]);
        if (request('product_image')){
            $imagePath = request('product_image')->store('ProductImages', 'public');
            $image = Image::make(public_path("storage/{$imagePath}"))->fit(520, 600);
            $data = array_merge($data,['product_image'=>$imagePath]);
        }
        $product->update($data);
        return redirect('/products');
    }
public function update ( Request $ request , Product $ product ) { $ data = request ( ) -> validate ( [ 'product_name' => 'required' , 'product_short_description' => 'required' , 'product_code' => 'required' , 'product_description' => 'required' , 'product_features' => 'required' , 'product_category' => 'required' , 'tags' => 'required' , 'product_image' => 'required' , ] ) ; if ( request ( 'product_image' ) ) { $ imagePath = request ( 'product_image' ) -> store ( 'ProductImages' , 'public' ) ; $ image = Image :: make ( public_path ( " storage/ { $ imagePath } " ) ) -> fit ( 520 , 600 ) ; $ data = array_merge ( $ data , [ 'product_image' => $ imagePath ] ) ; } $ product -> update ( $ data ) ; return redirect ( '/products' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .