@@ -26,8 +26,10 @@ public function rules(): array
26
26
'trigger ' => 'sometimes|string|max:255 ' ,
27
27
'subject ' => 'required|string|max:255 ' ,
28
28
'sender ' => ['sometimes ' , new ContactRule ()],
29
- 'cc ' => ['sometimes ' , new ContactRule ()],
30
- 'bcc ' => ['sometimes ' , new ContactRule ()],
29
+ 'cc ' => 'sometimes|array ' ,
30
+ 'bcc ' => 'sometimes|array ' ,
31
+ 'cc.* ' => [new ContactRule ()],
32
+ 'bcc.* ' => [new ContactRule ()],
31
33
'variables ' => 'sometimes|array ' ,
32
34
'tags ' => 'sometimes|array ' ,
33
35
'metadata ' => 'sometimes|array ' ,
@@ -65,8 +67,10 @@ public function rules(): array
65
67
Rule::when ($ this ->has ('recipients ' ) && is_array ($ this ->json ('recipients.0 ' )), 'required|email ' ),
66
68
],
67
69
'recipients.*.variables ' => 'sometimes|array ' ,
68
- 'recipients.*.cc ' => ['sometimes ' , new ContactRule ()],
69
- 'recipients.*.bcc ' => ['sometimes ' , new ContactRule ()],
70
+ 'recipients.*.cc ' => 'sometimes|array ' ,
71
+ 'recipients.*.cc.* ' => [new ContactRule ()],
72
+ 'recipients.*.bcc ' => 'sometimes|array ' ,
73
+ 'recipients.*.bcc.* ' => [new ContactRule ()],
70
74
71
75
// Recipients attachments
72
76
'recipients.*.attachments ' => 'sometimes|array ' ,
@@ -106,6 +110,26 @@ protected function prepareForValidation(): void
106
110
]);
107
111
}
108
112
113
+ // Wrap cc array list
114
+ if (
115
+ !is_null ($ this ->input ('cc ' ))
116
+ && (!is_array ($ this ->input ('cc ' )) || !array_is_list ($ this ->input ('cc ' )))
117
+ ) {
118
+ $ this ->merge ([
119
+ 'cc ' => [$ this ->input ('cc ' )],
120
+ ]);
121
+ }
122
+
123
+ // Wrap bcc array list
124
+ if (
125
+ !is_null ($ this ->input ('bcc ' ))
126
+ && (!is_array ($ this ->input ('bcc ' )) || !array_is_list ($ this ->input ('bcc ' )))
127
+ ) {
128
+ $ this ->merge ([
129
+ 'bcc ' => [$ this ->input ('bcc ' )],
130
+ ]);
131
+ }
132
+
109
133
// Wrap recipient array list into a structured data
110
134
if (is_array ($ this ->input ('recipients ' )) && !is_array ($ this ->json ('recipients.0 ' ))) {
111
135
$ this ->merge ([
@@ -118,6 +142,31 @@ protected function prepareForValidation(): void
118
142
]);
119
143
}
120
144
145
+ // Wrap recipient cc and bcc
146
+ $ recipients = $ this ->input ('recipients ' );
147
+
148
+ if (is_array ($ recipients )) {
149
+ foreach ($ recipients as $ i => $ recipient ) {
150
+ if (
151
+ array_key_exists ('cc ' , $ recipient )
152
+ && (!is_array ($ this ->input ('cc ' )) || !array_is_list ($ this ->input ('cc ' )))
153
+ ) {
154
+ $ recipients [$ i ]['cc ' ] = [$ recipient ['cc ' ]];
155
+ }
156
+
157
+ if (
158
+ array_key_exists ('bcc ' , $ recipient )
159
+ && (!is_array ($ this ->input ('bcc ' )) || !array_is_list ($ this ->input ('bcc ' )))
160
+ ) {
161
+ $ recipients [$ i ]['bcc ' ] = [$ recipient ['bcc ' ]];
162
+ }
163
+ }
164
+
165
+ $ this ->merge ([
166
+ 'recipients ' => $ recipients ,
167
+ ]);
168
+ }
169
+
121
170
// Wrap remote attachments array list into a structured data
122
171
if (is_array ($ this ->input ('remoteAttachments ' )) && !is_array ($ this ->json ('remoteAttachments.0 ' ))) {
123
172
$ this ->merge ([
0 commit comments