As you all know, the Eloquent is an ORM that is used by the Laravel framework. It has a very nice API for working with multiple database sources.

But today, I’m gonna talk about a weird behavior in Eloquent. I’ve faced a very uncommon race-condition issue in Eloquent ...OrCreate() methods, in my case, specifically the updateOrCreate() method. The race-condition issues are very rare in PHP programming so you may not be familiar with them (then read this).

This problem still exists even in Laravel 7 (reported here). Since they have closed the origin issue, I don’t know whether it still…

Erfan Sahafnejad

Back-End Engineer and DevOps enthusiast. Startup Lover.

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store