Laravel 5.1 Create or Update on Duplicate
问题 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 the answers were for old laravel versions. In one of the old topics it said that a new updateOrCreate() method was added in core last year. But when I try that, I am getting the error: Integrity constraint violation: 1062 Duplicate entry '1' for key 'app_id' This is the query I use: AppInfo::updateOrCreate(array( 'app_id' =>