melihovv / laravel-shopping-cart

Laravel shopping cart package
MIT License
73 stars 29 forks source link

Colum ID cannot be null error #17

Closed JamieCee20 closed 3 years ago

JamieCee20 commented 4 years ago

My code:

public function store(User $user, Request $request)
{
    // dd($request);
    $id = $request->id;
    $name = $request->name;
    $price = $request->price;

    $contentCart = Cart::instance('shopping')->add($id, $request->name, $request->price, 1);

    if(Cart::has($contentCart->getUniqueId())) {
        Cart::store($user->id)->content();
    }
    // Cart::store($user->id)->content();
    // return redirect()->route('cart.index')->with('success', 'Item was added to your cart');
}

DD() has proven request ID is not null, it just wont store apparently.

JamieCee20 commented 4 years ago

And when I run Cart::content();

{"bb4a6db4295d6be8bd12791ed5650087":{"unique_id":"bb4a6db4295d6be8bd12791ed5650087","id":"14","name":"Laptop 14","price":599999,"quantity":1,"options":[]}}

melihovv commented 4 years ago

I don't understand, what the problem is?

melihovv commented 3 years ago

Close due to inactivity