How to solve the Laravel Eloquent Duplicate issue
Integrity constraint violation: 1062 Duplicate entry '8' for key 'PRIMARY'
protected $primaryKey = 'user_id';
Now that you have added your primary key in your model, try to reuse the UpdateOrCreate method, you should not receive another duplication issue.
We decided to post this fix as many seem to struggle with this when using Laravel!
As an Amazon Associate I earn from qualifying purchases. This post may contain affiliate links which means I may receive a commission for purchases made through links.