File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -60,4 +60,15 @@ public function constraintsDescriptions(): array
6060 return array_merge ($ base , $ descriable ::conditions ());
6161 }, []);
6262 }
63+
64+ public function constraintsNotSatisfiedDescriptions (): array
65+ {
66+ return collect ($ this ->constraints )
67+ ->map (fn (string $ event ) => unserialize ($ event ))
68+ ->filter (fn ($ event ) => is_subclass_of ($ event , Descriptionable::class))
69+ ->filter (fn ($ event ) => !$ event ->canSend ($ this , $ this ->logs ))
70+ ->reduce (function ($ base , Descriptionable $ descriable ) {
71+ return array_merge ($ base , $ descriable ::conditions ());
72+ }, []);
73+ }
6374}
Original file line number Diff line number Diff line change 22
33namespace 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 ;
59use Carbon \Carbon ;
610use 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 */
1419class 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 ' ,
Original file line number Diff line number Diff line change 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 ;
@@ -381,7 +382,8 @@ public function markAsSent(): self
381382 {
382383 $ this ->logs ()
383384 ->create ([
384- // 'recipients' => $this->getRecipients(),
385+ 'recipients ' => $ this ->getRecipients (),
386+ 'name ' => $ this ->name ,
385387 'status ' => MailatorLog::STATUS_SENT ,
386388 'action_at ' => now (),
387389 'created_at ' => now (),
@@ -397,6 +399,8 @@ public function markAsSent(): self
397399 public function markAsFailed (string $ failureReason ): self
398400 {
399401 $ this ->logs ()->create ([
402+ 'recipients ' => $ this ->getRecipients (),
403+ 'name ' => $ this ->name ,
400404 'status ' => MailatorLog::STATUS_FAILED ,
401405 'action_at ' => now (),
402406 'created_at ' => now (),
You can’t perform that action at this time.
0 commit comments