2020use Illuminate \Database \Eloquent \Model ;
2121use Illuminate \Database \Eloquent \Relations \HasMany ;
2222use Illuminate \Support \Arr ;
23+ use Illuminate \Support \Collection ;
2324use Illuminate \Support \Facades \Validator ;
2425use Illuminate \Support \Str ;
2526use 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