A free open source IT asset/license management system
New Welcome Notification (#5146)
fordster78688a3251a91f
diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.phpindex 2b6f0c008a..8d7ae3cdb4 100755--- a/app/Http/Controllers/UsersController.php+++ b/app/Http/Controllers/UsersController.php@@ -34,6 +34,7 @@ use View;use Illuminate\Http\Request;use Gate;use Artisan;+use App\Notifications\WelcomeNotification;/*** This controller handles all actions related to Users for@@ -148,11 +149,13 @@ class UsersController extends Controller$data['first_name'] = e($request->input('first_name'));$data['password'] = e($request->input('password'));- Mail::send('emails.send-login', $data, function ($m) use ($user) {+ $user->notify(new WelcomeNotification($data));++/* Mail::send('emails.send-login', $data, function ($m) use ($user) {$m->to($user->email, $user->first_name . ' ' . $user->last_name);$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));$m->subject(trans('mail.welcome', ['name' => $user->first_name]));- });+ });*/}return redirect::route('users.index')->with('success', trans('admin/users/message.success.create'));}@@ -192,15 +195,17 @@ class UsersController extends Controller// Send the credentials through email$data = array();$data['email'] = $request->input('email');+ $data['username'] = $request->input('username');$data['first_name'] = $request->input('first_name');- $data['last_name'] = $request->input('last_name');$data['password'] = $request->input('password');- Mail::send('emails.send-login', $data, function ($m) use ($user) {+ $user->notify(new WelcomeNotification($data));++ /*Mail::send('emails.send-login', $data, function ($m) use ($user) {$m->to($user->email, $user->first_name . ' ' . $user->last_name);$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));$m->subject(trans('mail.welcome', ['name' => $user->first_name]));- });+ });*/}return JsonResponse::create($user);@@ -852,16 +857,20 @@ class UsersController extends Controller// Send the credentials through emailif ($row[3] != '') {$data = array();+ $data['email'] = trim(e($row[4]));$data['username'] = trim(e($row[2]));$data['first_name'] = trim(e($row[0]));$data['password'] = $pass;if ($newuser['email']) {- Mail::send('emails.send-login', $data, function ($m) use ($newuser) {+ $user = User::where('username', $row[2])->first();+ $user->notify(new WelcomeNotification($data));++ /*Mail::send('emails.send-login', $data, function ($m) use ($newuser) {$m->to($newuser['email'], $newuser['first_name'] . ' ' . $newuser['last_name']);$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));$m->subject(trans('mail.welcome', ['name' => $newuser['first_name']]));- });+ });*/}}}diff --git a/app/Notifications/WelcomeNotification.php b/app/Notifications/WelcomeNotification.phpnew file mode 100644index 0000000000..cc778b9cdf--- /dev/null+++ b/app/Notifications/WelcomeNotification.php@@ -0,0 +1,66 @@+<?php++namespace App\Notifications;++use Illuminate\Bus\Queueable;+use Illuminate\Notifications\Notification;+use Illuminate\Contracts\Queue\ShouldQueue;+use Illuminate\Notifications\Messages\MailMessage;++class WelcomeNotification extends Notification+{+ use Queueable;++ private $_data = array();++ /**+ * Create a new notification instance.+ *+ * @return void+ */+ public function __construct(array $content)+ {+ $this->_data['email'] = $content['email'];+ $this->_data['first_name'] = $content['first_name'];+ $this->_data['username'] = $content['username'];+ $this->_data['password'] = $content['password'];+ $this->_data['url'] = url('/');+ }++ /**+ * Get the notification's delivery channels.+ *+ * @param mixed $notifiable+ * @return array+ */+ public function via($notifiable)+ {+ return ['mail'];+ }++ /**+ * Get the mail representation of the notification.+ *+ * @param mixed $notifiable+ * @return \Illuminate\Notifications\Messages\MailMessage+ */+ public function toMail($notifiable)+ {+ return (new MailMessage)+ ->subject(trans('mail.welcome', ['name' => $this->_data['first_name'] ]))+ ->markdown('notifications.Welcome', $this->_data);+ }++ /**+ * Get the array representation of the notification.+ *+ * @param mixed $notifiable+ * @return array+ */+ public function toArray($notifiable)+ {+ return [+ //+ ];+ }+}diff --git a/resources/views/notifications/Test.blade.php b/resources/views/notifications/Test.blade.phpindex a651f2f3f1..a7e2be1c58 100644--- a/resources/views/notifications/Test.blade.php+++ b/resources/views/notifications/Test.blade.php@@ -3,5 +3,9 @@{{ trans('mail.test_mail_text') }}Thanks,<br>-{{ $snipeSettings->site_name }}+ @if ($snipeSettings->show_url_in_emails=='1')+ <p><a href="{{ url('/') }}">{{ $snipeSettings->site_name }}</a></p>+ @else+ <p>{{ $snipeSettings->site_name }}</p>+ @endif@endcomponentdiff --git a/resources/views/notifications/Welcome.blade.php b/resources/views/notifications/Welcome.blade.phpnew file mode 100644index 0000000000..fb41854352--- /dev/null+++ b/resources/views/notifications/Welcome.blade.php@@ -0,0 +1,19 @@+@component('mail::message')+{{ trans('mail.hello') }} {{ $first_name }},++{{ trans('mail.admin_has_created', ['web' => $snipeSettings->site_name]) }}++{{ trans('mail.login') }} {{ $username }} <br>+{{ trans('mail.password') }} {{ $password }}++@component('mail::button', ['url' => $url])+Go To {{$snipeSettings->site_name}}+@endcomponent++{{ trans('mail.best_regards') }} <br>+@if ($snipeSettings->show_url_in_emails=='1')+ <p><a href="{{ url('/') }}">{{ $snipeSettings->site_name }}</a></p>+@else+ <p>{{ $snipeSettings->site_name }}</p>+@endif+@endcomponent