In Laravel 5.1, for MySQL insert, I want to see if the record already exists and update on duplicate or create new if none exists.
I have already searched SO where t
In my case this was caused by a simple mismatch on the auto incrementing key in my model table.
Getting the current max id:
SELECT max(id) from companies
Then setting the sequence value one higher:
select setval('companies_id_seq', 164);
eliminated the error.