Skip to content

Commit 56b0d26

Browse files
committed
Filter out myself when saving
1 parent 8c96cd0 commit 56b0d26

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Models/MailatorSchedule.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Closure;
2121
use Exception;
2222
use Illuminate\Contracts\Mail\Mailable;
23+
use Illuminate\Database\Eloquent\Builder;
2324
use Illuminate\Database\Eloquent\Model;
2425
use Illuminate\Database\Eloquent\Relations\HasMany;
2526
use Illuminate\Support\Arr;
@@ -373,10 +374,6 @@ public function shouldSend(): bool
373374

374375
public function executeWhenPasses(bool $now = false): void
375376
{
376-
if (! $this->save()) {
377-
return;
378-
}
379-
380377
if ($this->shouldSend()) {
381378
$this->execute($now);
382379
}
@@ -586,6 +583,9 @@ public function save(array $options = [])
586583
->targetableId($this->targetable_id)
587584
->mailableClass($mailable)
588585
->where('name', $this->name)
586+
->when($this->getKey(), function(Builder $q) {
587+
$q->where($this->getKeyName(), '!=', $this->getKey());
588+
})
589589
->exists();
590590

591591
if ($exists) {

0 commit comments

Comments
 (0)