From: Louis Jeckel Date: Thu, 29 Oct 2020 14:06:41 +0000 (+0100) Subject: required subject X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=38a968c7f00c49fced51fe6035c4f706168a491d;p=psq.git required subject --- diff --git a/app/Nova/Actions/SendCustomNotification.php b/app/Nova/Actions/SendCustomNotification.php index 97f5b67..a03a3ee 100644 --- a/app/Nova/Actions/SendCustomNotification.php +++ b/app/Nova/Actions/SendCustomNotification.php @@ -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(), ]; }