diff --git a/Actions/BuildMailMessageAction.php b/Actions/BuildMailMessageAction.php index 13d5dc2d..6abdff8a 100755 --- a/Actions/BuildMailMessageAction.php +++ b/Actions/BuildMailMessageAction.php @@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Notifications\Messages\MailMessage; +<<<<<<< HEAD use Modules\Notify\Datas\AttachmentData; use Spatie\LaravelData\DataCollection; use Spatie\QueueableAction\QueueableAction; @@ -42,5 +43,65 @@ public function execute( } return $email; +======= +use Illuminate\Support\Str; +use Modules\Notify\Models\NotifyTheme; +use Spatie\QueueableAction\QueueableAction; + +class BuildMailMessageAction { + use QueueableAction; + + public function execute(string $name, Model $model, array $view_params): MailMessage { + $view_params = array_merge($view_params, $model->toArray()); + $type='email'; + $theme = NotifyTheme::firstOrCreate([ + 'lang' => $view_params['lang'] ?? app()->getLocale(), + 'type' => $type, // email,sms,whatsapp,piccione + 'post_type' => $name, + 'post_id' => $view_params['post_id'] ?? 0, + ]); + + + + + if (null == $theme->subject) { + $subject = trans('lu::auth.'.$name.'.subject'); + $theme->update(['subject' => $subject]); + } + if (null == $theme->theme) { + $theme->update(['theme' => 'ark']); + } + if (null == $theme->body_html) { + $html = trans('lu::auth.'.$name.'.body_html'); + + if ('verify-email' == $name && 3 == $view_params['post_id']) { + $html .= '
When you\'ll re-login this will be your password: ##password##'; + } + + $theme->update(['body_html' => $html]); + } + $view_params = array_merge($view_params, $theme->toArray()); + // $this->view_params['url'] = (string)$url; + + $body_html = $theme->body_html; + foreach ($view_params as $k => $v) { + if (is_string($v)) { + $body_html = Str::replace('##'.$k.'##', $v, $body_html); + } + } + + $view_params['body_html'] = $body_html; + + $view_html = 'lu::auth.emails.html'; + + // $out = view($view_html, $this->view_params); + // dddx($this->view_params); + // die($out->render()); + + return (new MailMessage()) + // ->from('barrett@example.com', 'Barrett Blair') + ->subject($theme->subject) + ->view($view_html, $view_params); +>>>>>>> 5da1f59 (up) } } diff --git a/Actions/BuildUserMailMessageAction.php b/Actions/BuildUserMailMessageAction.php deleted file mode 100644 index 1eac5262..00000000 --- a/Actions/BuildUserMailMessageAction.php +++ /dev/null @@ -1,68 +0,0 @@ -toArray()); - $type='email'; - $theme = NotifyTheme::firstOrCreate([ - 'lang' => $view_params['lang'] ?? app()->getLocale(), - 'type' => $type, // email,sms,whatsapp,piccione - 'post_type' => $name, - 'post_id' => $view_params['post_id'] ?? 0, - ]); - - - - - if (null == $theme->subject) { - $subject = trans('lu::auth.'.$name.'.subject'); - $theme->update(['subject' => $subject]); - } - if (null == $theme->theme) { - $theme->update(['theme' => 'ark']); - } - if (null == $theme->body_html) { - $html = trans('lu::auth.'.$name.'.body_html'); - - if ('verify-email' == $name && 3 == $view_params['post_id']) { - $html .= '
When you\'ll re-login this will be your password: ##password##'; - } - - $theme->update(['body_html' => $html]); - } - $view_params = array_merge($view_params, $theme->toArray()); - // $this->view_params['url'] = (string)$url; - - $body_html = $theme->body_html; - foreach ($view_params as $k => $v) { - if (is_string($v)) { - $body_html = Str::replace('##'.$k.'##', $v, $body_html); - } - } - - $view_params['body_html'] = $body_html; - - $view_html = 'lu::auth.emails.html'; - - // $out = view($view_html, $this->view_params); - // dddx($this->view_params); - // die($out->render()); - - return (new MailMessage()) - // ->from('barrett@example.com', 'Barrett Blair') - ->subject($theme->subject) - ->view($view_html, $view_params); - } -}