Race condition workarounds for concurrent *OrCreate
method calls.
Apply the CanRunOrCreateConcurrently
trait to a model:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Kekalainen\EloquentConcurrency\CanRunOrCreateConcurrently;
abstract class BaseModel extends Model
{
use CanRunOrCreateConcurrently;
}
- Only MySQL and MariaDB are supported.
- Relationship methods are not handled.