mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
New First Admin Notification (#5147)
* New First Admin Notification * Include Last name in Welcome and First admin Notifications
This commit is contained in:
parent
688a3251a9
commit
68a9855506
|
@ -22,6 +22,7 @@ use App\Http\Requests\SetupUserRequest;
|
|||
use App\Http\Requests\ImageUploadRequest;
|
||||
use App\Http\Requests\SettingsLdapRequest;
|
||||
use App\Helpers\Helper;
|
||||
use App\Notifications\FirstAdminNotification;
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Settings for
|
||||
|
@ -186,11 +187,20 @@ class SettingsController extends Controller
|
|||
$settings->save();
|
||||
|
||||
if (Input::get('email_creds')=='1') {
|
||||
Mail::send(['text' => 'emails.firstadmin'], $data, function ($m) use ($data) {
|
||||
$data = array();
|
||||
$data['email'] = $user->email;
|
||||
$data['username'] = $user->username;
|
||||
$data['first_name'] = $user->first_name;
|
||||
$data['last_name'] = $user->last_name;
|
||||
$data['password'] = $user->password;
|
||||
|
||||
$user->notify(new FirstAdminNotification($data));
|
||||
|
||||
/*Mail::send(['text' => 'emails.firstadmin'], $data, function ($m) use ($data) {
|
||||
$m->to($data['email'], $data['first_name']);
|
||||
$m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
|
||||
$m->subject(trans('mail.your_credentials'));
|
||||
});
|
||||
});*/
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -147,6 +147,7 @@ class UsersController extends Controller
|
|||
$data['email'] = e($request->input('email'));
|
||||
$data['username'] = e($request->input('username'));
|
||||
$data['first_name'] = e($request->input('first_name'));
|
||||
$data['last_name'] = e($request->input('last_name'));
|
||||
$data['password'] = e($request->input('password'));
|
||||
|
||||
$user->notify(new WelcomeNotification($data));
|
||||
|
@ -197,6 +198,7 @@ class UsersController extends Controller
|
|||
$data['email'] = $request->input('email');
|
||||
$data['username'] = $request->input('username');
|
||||
$data['first_name'] = $request->input('first_name');
|
||||
$data['last_name'] = e($request->input('last_name'));
|
||||
$data['password'] = $request->input('password');
|
||||
|
||||
$user->notify(new WelcomeNotification($data));
|
||||
|
@ -860,6 +862,7 @@ class UsersController extends Controller
|
|||
$data['email'] = trim(e($row[4]));
|
||||
$data['username'] = trim(e($row[2]));
|
||||
$data['first_name'] = trim(e($row[0]));
|
||||
$data['last_name'] = trim(e($row[1]));
|
||||
$data['password'] = $pass;
|
||||
|
||||
if ($newuser['email']) {
|
||||
|
|
67
app/Notifications/FirstAdminNotification.php
Normal file
67
app/Notifications/FirstAdminNotification.php
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class FirstAdminNotification 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['last_name'] = $content['last_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'] . ' ' . $this->_data['last_name'] ]))
|
||||
->markdown('notifications.FirstAdmin', $this->_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($notifiable)
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
|
@ -22,6 +22,7 @@ class WelcomeNotification extends Notification
|
|||
{
|
||||
$this->_data['email'] = $content['email'];
|
||||
$this->_data['first_name'] = $content['first_name'];
|
||||
$this->_data['last_name'] = $content['last_name'];
|
||||
$this->_data['username'] = $content['username'];
|
||||
$this->_data['password'] = $content['password'];
|
||||
$this->_data['url'] = url('/');
|
||||
|
@ -47,7 +48,7 @@ class WelcomeNotification extends Notification
|
|||
public function toMail($notifiable)
|
||||
{
|
||||
return (new MailMessage)
|
||||
->subject(trans('mail.welcome', ['name' => $this->_data['first_name'] ]))
|
||||
->subject(trans('mail.welcome', ['name' => $this->_data['first_name'] . ' ' . $this->_data['last_name'] ]))
|
||||
->markdown('notifications.Welcome', $this->_data);
|
||||
}
|
||||
|
||||
|
|
17
resources/views/notifications/FirstAdmin.blade.php
Normal file
17
resources/views/notifications/FirstAdmin.blade.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
@component('mail::message')
|
||||
{{ trans('mail.hello') }} {{ $first_name }} {{$last_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
|
|
@ -1,5 +1,5 @@
|
|||
@component('mail::message')
|
||||
{{ trans('mail.hello') }} {{ $first_name }},
|
||||
{{ trans('mail.hello') }} {{ $first_name }} {{$last_name}},
|
||||
|
||||
{{ trans('mail.admin_has_created', ['web' => $snipeSettings->site_name]) }}
|
||||
|
||||
|
|
Loading…
Reference in a new issue