diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php
index 2b6f0c008ab2..8d7ae3cdb4c4 100755
--- a/app/Http/Controllers/UsersController.php
+++ b/app/Http/Controllers/UsersController.php
@@ -34,6 +34,7 @@
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 @@ public function store(SaveUserRequest $request)
$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 @@ public function apiStore(SaveUserRequest $request)
// 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 @@ public function postImport()
// Send the credentials through email
if ($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.php
new file mode 100644
index 000000000000..cc778b9cdfba
--- /dev/null
+++ b/app/Notifications/WelcomeNotification.php
@@ -0,0 +1,66 @@
+_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.php
index a651f2f3f1f2..a7e2be1c58b5 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,
-{{ $snipeSettings->site_name }}
+ @if ($snipeSettings->show_url_in_emails=='1')
+
{{ $snipeSettings->site_name }}
+ @else +{{ $snipeSettings->site_name }}
+ @endif @endcomponent diff --git a/resources/views/notifications/Welcome.blade.php b/resources/views/notifications/Welcome.blade.php new file mode 100644 index 000000000000..fb41854352d0 --- /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 }}{{ $snipeSettings->site_name }}
+@else +{{ $snipeSettings->site_name }}
+@endif +@endcomponent