Skip to content

Commit e014ccc

Browse files
committed
revert to cast for recipients
1 parent 17811a6 commit e014ccc

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/Models/MailatorLog.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22

33
namespace Binarcode\LaravelMailator\Models;
44

5+
use Binarcode\LaravelMailator\Models\Concerns\ConstraintsResolver;
6+
use Binarcode\LaravelMailator\Models\Concerns\HasFuture;
7+
use Binarcode\LaravelMailator\Models\Concerns\HasTarget;
8+
use Binarcode\LaravelMailator\Support\ClassResolver;
59
use Carbon\Carbon;
610
use Illuminate\Database\Eloquent\Model;
711

812
/**
913
* Class MailatorLog
1014
* @property string $status
1115
* @property Carbon $created_at
16+
* @property array recipients
1217
* @package Binarcode\LaravelMailator\Models
1318
*/
1419
class MailatorLog extends Model
@@ -32,7 +37,7 @@ public function getTable()
3237
'updated_at',
3338
];
3439

35-
protected $cast = [
40+
protected $casts = [
3641
'action_at' => 'datetime',
3742
'created_at' => 'datetime',
3843
'updated_at' => 'datetime',

src/Models/MailatorSchedule.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ public function markAsSent(): self
381381
{
382382
$this->logs()
383383
->create([
384-
'recipients' => json_encode($this->getRecipients()),
384+
'recipients' => $this->getRecipients(),
385385
'name' => $this->name,
386386
'status' => MailatorLog::STATUS_SENT,
387387
'action_at' => now(),
@@ -398,7 +398,7 @@ public function markAsSent(): self
398398
public function markAsFailed(string $failureReason): self
399399
{
400400
$this->logs()->create([
401-
'recipients' => json_encode($this->getRecipients()),
401+
'recipients' => $this->getRecipients(),
402402
'name' => $this->name,
403403
'status' => MailatorLog::STATUS_FAILED,
404404
'action_at' => now(),
@@ -418,7 +418,8 @@ public function markAsFailed(string $failureReason): self
418418
public function getRecipients(): array
419419
{
420420
return collect($this->recipients)
421-
->filter(fn ($email) => $this->ensureValidEmail($email));
421+
->filter(fn ($email) => $this->ensureValidEmail($email))
422+
->toArray();
422423
}
423424

424425
protected function ensureValidEmail(string $email): bool

0 commit comments

Comments
 (0)