app/Http/Controllers/ProductController.php
/**
     * Remove the specified resource from storage.
     *
     * @param \App\Product $product
     * @return \Illuminate\Http\Response
     */
Remove the specified resource from storage.
Remove the specified resource from storage .
public function destroy(Product $product)
    {
        $cart = new Cart(session()->get('cart'));
        $cart->remove($product->id);
        if ($cart->totalQuantity <= 0) {
            session()->forget('cart');
        } else {
            session()->put('cart', $cart);
        }
        return redirect()->route('cart.show')->with('success', 'product was removed');
    }
public function destroy ( Product $ product ) { $ cart = new Cart ( session ( ) -> get ( 'cart' ) ) ; $ cart -> remove ( $ product -> id ) ; if ( $ cart -> totalQuantity <= 0 ) { session ( ) -> forget ( 'cart' ) ; } else { session ( ) -> put ( 'cart' , $ cart ) ; } return redirect ( ) -> route ( 'cart.show' ) -> with ( 'success' , 'product was removed' ) ; }
Remove the specified resource from storage.
Remove the specified resource from storage .