mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
New Welcome Notification (#5146)
* New Test Notification Created Test Notification. Updated Vendor Mail message.blade files. Updated api settings controller to use Notification Façade. * Add show URL in Emails condition * New Welcome Notification
This commit is contained in:
parent
30c5cc1dc4
commit
688a3251a9
|
@ -34,6 +34,7 @@ use View;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Gate;
|
use Gate;
|
||||||
use Artisan;
|
use Artisan;
|
||||||
|
use App\Notifications\WelcomeNotification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This controller handles all actions related to Users for
|
* 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['first_name'] = e($request->input('first_name'));
|
||||||
$data['password'] = e($request->input('password'));
|
$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->to($user->email, $user->first_name . ' ' . $user->last_name);
|
||||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||||
$m->subject(trans('mail.welcome', ['name' => $user->first_name]));
|
$m->subject(trans('mail.welcome', ['name' => $user->first_name]));
|
||||||
});
|
});*/
|
||||||
}
|
}
|
||||||
return redirect::route('users.index')->with('success', trans('admin/users/message.success.create'));
|
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
|
// Send the credentials through email
|
||||||
$data = array();
|
$data = array();
|
||||||
$data['email'] = $request->input('email');
|
$data['email'] = $request->input('email');
|
||||||
|
$data['username'] = $request->input('username');
|
||||||
$data['first_name'] = $request->input('first_name');
|
$data['first_name'] = $request->input('first_name');
|
||||||
$data['last_name'] = $request->input('last_name');
|
|
||||||
$data['password'] = $request->input('password');
|
$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->to($user->email, $user->first_name . ' ' . $user->last_name);
|
||||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||||
$m->subject(trans('mail.welcome', ['name' => $user->first_name]));
|
$m->subject(trans('mail.welcome', ['name' => $user->first_name]));
|
||||||
});
|
});*/
|
||||||
}
|
}
|
||||||
|
|
||||||
return JsonResponse::create($user);
|
return JsonResponse::create($user);
|
||||||
|
@ -852,16 +857,20 @@ class UsersController extends Controller
|
||||||
// Send the credentials through email
|
// Send the credentials through email
|
||||||
if ($row[3] != '') {
|
if ($row[3] != '') {
|
||||||
$data = array();
|
$data = array();
|
||||||
|
$data['email'] = trim(e($row[4]));
|
||||||
$data['username'] = trim(e($row[2]));
|
$data['username'] = trim(e($row[2]));
|
||||||
$data['first_name'] = trim(e($row[0]));
|
$data['first_name'] = trim(e($row[0]));
|
||||||
$data['password'] = $pass;
|
$data['password'] = $pass;
|
||||||
|
|
||||||
if ($newuser['email']) {
|
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->to($newuser['email'], $newuser['first_name'] . ' ' . $newuser['last_name']);
|
||||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||||
$m->subject(trans('mail.welcome', ['name' => $newuser['first_name']]));
|
$m->subject(trans('mail.welcome', ['name' => $newuser['first_name']]));
|
||||||
});
|
});*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
66
app/Notifications/WelcomeNotification.php
Normal file
66
app/Notifications/WelcomeNotification.php
Normal file
|
@ -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 [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,5 +3,9 @@
|
||||||
{{ trans('mail.test_mail_text') }}
|
{{ trans('mail.test_mail_text') }}
|
||||||
|
|
||||||
Thanks,<br>
|
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
|
||||||
@endcomponent
|
@endcomponent
|
||||||
|
|
19
resources/views/notifications/Welcome.blade.php
Normal file
19
resources/views/notifications/Welcome.blade.php
Normal file
|
@ -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
|
Loading…
Reference in a new issue