]> _ Git - psq.git/commitdiff
required subject
authorLouis Jeckel <louis.jeckel@outlook.com>
Thu, 29 Oct 2020 14:06:41 +0000 (15:06 +0100)
committerLouis Jeckel <louis.jeckel@outlook.com>
Thu, 29 Oct 2020 14:06:41 +0000 (15:06 +0100)
app/Nova/Actions/SendCustomNotification.php

index 97f5b674aa506a7a8dad0cae117c2eeb9476ebe1..a03a3ee7129481d5dfe964b192cfdb691cf20798 100644 (file)
@@ -50,6 +50,9 @@ class SendCustomNotification extends Action
      */
     public function handle(ActionFields $fields, Collection $models)
     {
+        if(empty($fields->subject) || empty($fields->content)) {
+            return Action::danger('Merci de remplir tout le formulaire');
+        }
         $models->map(fn($sendsEmail) => $sendsEmail->sendTemplateEmail($fields->subject, $fields->content));
 
         return Action::message(sprintf('%d messages envoyés', $models->count()));
@@ -63,8 +66,8 @@ class SendCustomNotification extends Action
     public function fields()
     {
         return [
-            Text::make('Sujet', 'subject')->withMeta(['value' => $this->template->subject]),
-            Trix::make('Contenu', 'content')->withMeta(['value' => $this->template->content]),
+            Text::make('Sujet', 'subject')->withMeta(['value' => $this->template->subject])->required(),
+            Trix::make('Contenu', 'content')->withMeta(['value' => $this->template->content])->required(),
         ];
     }