@@ -157,33 +157,33 @@ public function newComment(Comment $comment, $request)
157157 // Selected recipients
158158 $ c_recipients = $ comment ->type == 'note ' ? $ request ->note_recipients : $ request ->reply_recipients ;
159159
160- foreach ($ c_recipients as $ member_id ){
161- $ recipient = Member::find ($ member_id );
162- if (count ($ recipient ) == 1 ){
163- // Register the notified email
164- $ notification = CommentNotification::create ([
165- 'comment_id ' => $ comment ->id ,
166- 'name ' => $ recipient ->name ,
167- 'email ' => $ recipient ->email ,
168- 'member_id ' => $ member_id
169- ]);
170-
171- // Add email to actual mail recipients
172- $ a_to [] = [
173- 'recipient ' => $ recipient ,
174- 'subject ' => $ subject ,
175- 'template ' => $ template
176- ];
160+ if (count ($ c_recipients ) > 0 ){
161+ foreach ($ c_recipients as $ member_id ){
162+ $ recipient = Member::find ($ member_id );
163+ if (count ($ recipient ) == 1 ){
164+ // Register the notified email
165+ $ notification = CommentNotification::create ([
166+ 'comment_id ' => $ comment ->id ,
167+ 'name ' => $ recipient ->name ,
168+ 'email ' => $ recipient ->email ,
169+ 'member_id ' => $ member_id
170+ ]);
171+
172+ // Add email to actual mail recipients
173+ $ a_to [] = [
174+ 'recipient ' => $ recipient ,
175+ 'subject ' => $ subject ,
176+ 'template ' => $ template
177+ ];
178+ }
177179 }
178180
181+ if ($ request ->has ('add_in_user_notification_text ' ) or (isset ($ comment ->add_in_user_notification_text ))){
182+ // Element in request comes from Comment modal
183+ // $comment property comes from an embedded comment when editing or creating a ticket
184+ $ data ['add_in_user_notification_text ' ] = true ;
185+ }
179186 }
180-
181- if ($ request ->has ('add_in_user_notification_text ' ) or (isset ($ comment ->add_in_user_notification_text ))){
182- // Element in request comes from Comment modal
183- // $comment property comes from an embedded comment when editing or creating a ticket
184- $ data ['add_in_user_notification_text ' ] = true ;
185- }
186-
187187 }
188188
189189 // Send notifications
0 commit comments