public function preventOverlapping()
{
$this->preventOverlapping = true;
// Skip the event if it's locked (processing)
$this->skip(function () {
return $this->isLocked();
});
// Delete the lock file when the event is completed
$this->after(function () {
$lockfile = $this->lockFile();
if (file_exists($lockfile)) {
unlink($lockfile);
}
});
return $this;
}