When use belongsTo go right way
$product->Category()->associate($category); $product->save();
Changed it like you said, though still getting the same error
Finally figured it out, had to use sync()
For anyone else that is having the same issue here's the fix:
$product->Category()->sync([$category->id]);
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community