Skip to content

Commit 680a569

Browse files
committed
Save logs
1 parent 5d80f3c commit 680a569

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Models/MailatorSchedule.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Illuminate\Database\Eloquent\Model;
2121
use Illuminate\Database\Eloquent\Relations\HasMany;
2222
use Illuminate\Support\Arr;
23+
use Illuminate\Support\Collection;
2324
use Illuminate\Support\Facades\Validator;
2425
use Illuminate\Support\Str;
2526
use Opis\Closure\SerializableClosure;
@@ -380,7 +381,8 @@ public function markAsSent(): self
380381
{
381382
$this->logs()
382383
->create([
383-
// 'recipients' => $this->getRecipients(),
384+
'recipients' => $this->getRecipients()->toJson(),
385+
'name' => $this->name,
384386
'status' => MailatorLog::STATUS_SENT,
385387
'action_at' => now(),
386388
'created_at' => now(),
@@ -396,6 +398,8 @@ public function markAsSent(): self
396398
public function markAsFailed(string $failureReason): self
397399
{
398400
$this->logs()->create([
401+
'recipients' => $this->getRecipients()->toJson(),
402+
'name' => $this->name,
399403
'status' => MailatorLog::STATUS_FAILED,
400404
'action_at' => now(),
401405
'created_at' => now(),
@@ -411,11 +415,10 @@ public function markAsFailed(string $failureReason): self
411415
return $this;
412416
}
413417

414-
public function getRecipients(): array
418+
public function getRecipients(): \Collection
415419
{
416420
return collect($this->recipients)
417-
->filter(fn ($email) => $this->ensureValidEmail($email))
418-
->toArray();
421+
->filter(fn ($email) => $this->ensureValidEmail($email));
419422
}
420423

421424
protected function ensureValidEmail(string $email): bool

0 commit comments

Comments
 (0)