Skip to content

Commit 9de2ed5

Browse files
authored
make sure there are recipients or throw a warning (alexjustesen#177)
1 parent 520fb57 commit 9de2ed5

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

app/Filament/Pages/Settings/NotificationPage.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ protected function getFormSchema(): array
100100
->label('Recipients')
101101
->schema([
102102
TextInput::make('email_address')
103-
->email()
104-
->required(fn (Closure $get) => $get('mail_enabled') == true),
103+
->email(),
105104
])
106105
->hidden(fn (Closure $get) => $get('mail_enabled') !== true)
107106
->columnSpan(['md' => 2]),
@@ -152,14 +151,21 @@ public function sendTestMailNotification()
152151
{
153152
$notificationSettings = new (NotificationSettings::class);
154153

155-
foreach ($notificationSettings->mail_recipients as $recipient) {
156-
Mail::to($recipient)
157-
->send(new Test());
158-
}
154+
if (count($notificationSettings->mail_recipients)) {
155+
foreach ($notificationSettings->mail_recipients as $recipient) {
156+
Mail::to($recipient)
157+
->send(new Test());
158+
}
159159

160-
Notification::make()
161-
->title('Test mail notification sent.')
162-
->success()
163-
->send();
160+
Notification::make()
161+
->title('Test mail notification sent.')
162+
->success()
163+
->send();
164+
} else {
165+
Notification::make()
166+
->title('You need to add recipients to receive mail notifications.')
167+
->warning()
168+
->send();
169+
}
164170
}
165171
}

0 commit comments

Comments
 (0)