Enahancement Done

This commit is contained in:
Devansh 2020-08-01 15:07:51 +05:30
parent e6d11ed809
commit f05b17aa99
19 changed files with 258 additions and 5 deletions

View File

@ -0,0 +1,31 @@
<?php
namespace Webkul\Admin\Listeners;
use Illuminate\Support\Facades\Mail;
use Webkul\User\Notifications\AdminUpdatePassword;
use Webkul\Customer\Notifications\CustomerUpdatePassword;
class PasswordChange
{
/**
* Send mail on updating password.
*
* @param \Webkul\Customer\Models\Customer|\Webkul\User\Models\Admin $adminOrCustomer
* @return void
*/
public function sendUpdatePasswordMail($adminOrCustomer)
{
try {
if ($adminOrCustomer instanceof \Webkul\Customer\Models\Customer) {
Mail::queue(new CustomerUpdatePassword($adminOrCustomer));
}
if ($adminOrCustomer instanceof \Webkul\User\Models\Admin) {
Mail::queue(new AdminUpdatePassword($adminOrCustomer));
}
} catch (\Exception $e) {
report($e);
}
}
}

View File

@ -14,6 +14,8 @@ class EventServiceProvider extends ServiceProvider
*/ */
public function boot() public function boot()
{ {
Event::listen('user.admin.update-password', 'Webkul\Admin\Listeners\PasswordChange@sendUpdatePasswordMail');
Event::listen('checkout.order.save.after', 'Webkul\Admin\Listeners\Order@sendNewOrderMail'); Event::listen('checkout.order.save.after', 'Webkul\Admin\Listeners\Order@sendNewOrderMail');
Event::listen('sales.invoice.save.after', 'Webkul\Admin\Listeners\Order@sendNewInvoiceMail'); Event::listen('sales.invoice.save.after', 'Webkul\Admin\Listeners\Order@sendNewInvoiceMail');

View File

@ -82,6 +82,7 @@ class CustomerController extends Controller
*/ */
public function update() public function update()
{ {
$isPasswordChanged = false;
$id = auth()->guard('customer')->user()->id; $id = auth()->guard('customer')->user()->id;
$this->validate(request(), [ $this->validate(request(), [
@ -104,6 +105,7 @@ class CustomerController extends Controller
if (isset ($data['oldpassword'])) { if (isset ($data['oldpassword'])) {
if ($data['oldpassword'] != "" || $data['oldpassword'] != null) { if ($data['oldpassword'] != "" || $data['oldpassword'] != null) {
if (Hash::check($data['oldpassword'], auth()->guard('customer')->user()->password)) { if (Hash::check($data['oldpassword'], auth()->guard('customer')->user()->password)) {
$isPasswordChanged = true;
$data['password'] = bcrypt($data['password']); $data['password'] = bcrypt($data['password']);
} else { } else {
session()->flash('warning', trans('shop::app.customer.account.profile.unmatch')); session()->flash('warning', trans('shop::app.customer.account.profile.unmatch'));
@ -119,6 +121,10 @@ class CustomerController extends Controller
if ($customer = $this->customerRepository->update($data, $id)) { if ($customer = $this->customerRepository->update($data, $id)) {
if ($isPasswordChanged) {
Event::dispatch('user.admin.update-password', $customer);
}
Event::dispatch('customer.update.after', $customer); Event::dispatch('customer.update.after', $customer);
Session()->flash('success', trans('shop::app.customer.account.profile.edit-success')); Session()->flash('success', trans('shop::app.customer.account.profile.edit-success'));

View File

@ -0,0 +1,43 @@
<?php
namespace Webkul\Customer\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class CustomerUpdatePassword extends Mailable
{
use Queueable, SerializesModels;
/**
* The admin instance.
*
* @var \Webkul\User\Contracts\Admin $admin
*/
public $customer;
/**
* Create a new message instance.
*
* @param \Webkul\User\Contracts\Admin $admin
* @return void
*/
public function __construct($customer)
{
$this->customer = $customer;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($this->customer->email, $this->customer->name)
->subject(trans('shop::app.mail.update-password.subject'))
->view('shop::emails.customer.update-password', ['user' => $this->customer]);
}
}

View File

@ -635,6 +635,13 @@ return [
'thanks' => 'شكرا!' 'thanks' => 'شكرا!'
], ],
'update-password' => [
'subject' => 'تم تحديث كلمة السر',
'dear' => ':name عزيزي',
'info' => 'أنت تتلقى هذا البريد الإلكتروني لأنك قمت بتحديث كلمة المرور الخاصة بك.',
'thanks' => 'شكرا!'
],
'customer' => [ 'customer' => [
'new' => [ 'new' => [
'dear' => ':customer_name العزيز', 'dear' => ':customer_name العزيز',

View File

@ -629,6 +629,13 @@ return [
'thanks' => 'Vielen Dank!' 'thanks' => 'Vielen Dank!'
], ],
'update-password' => [
'subject' => 'Passwort aktualisiert',
'dear' => 'Sehr geehrte/r :name',
'info' => 'Sie erhalten diese E-Mail, weil Sie Ihr Passwort aktualisiert haben.',
'thanks' => 'Vielen Dank!'
],
'customer' => [ 'customer' => [
'new' => [ 'new' => [
'dear' => 'Sehr geehrte/r :customer_name', 'dear' => 'Sehr geehrte/r :customer_name',

View File

@ -644,6 +644,13 @@ return [
'thanks' => 'Thanks!' 'thanks' => 'Thanks!'
], ],
'update-password' => [
'subject' => 'Password Updated',
'dear' => 'Dear :name',
'info' => 'You are receiving this email because you have updated your password.',
'thanks' => 'Thanks!'
],
'customer' => [ 'customer' => [
'new' => [ 'new' => [
'dear' => 'Dear :customer_name', 'dear' => 'Dear :customer_name',

View File

@ -582,6 +582,12 @@ return [
'final-summary' => 'Si no has solicitado cambiar de contraseña, ninguna acción es requerida por tu parte.', 'final-summary' => 'Si no has solicitado cambiar de contraseña, ninguna acción es requerida por tu parte.',
'thanks' => '¡Gracias!' 'thanks' => '¡Gracias!'
], ],
'update-password' => [
'subject' => 'Contraseña actualiza',
'dear' => 'Estimado/a :name',
'info' => 'Está recibiendo este correo electrónico porque ha actualizado su contraseña.',
'thanks' => '¡Gracias!'
],
'customer' => [ 'customer' => [
'new' => [ 'new' => [
'dear' => 'Estimado/a :customer_name', 'dear' => 'Estimado/a :customer_name',

View File

@ -634,6 +634,13 @@ return [
'thanks' => 'با تشکر' 'thanks' => 'با تشکر'
], ],
'update-password' => [
'subject' => 'پسورد آپدیت شد',
'dear' => ':name عزیز',
'info' => 'شما این ایمیل را دریافت می کنید زیرا رمز خود را به روز کرده اید.',
'thanks' => 'با تشکر'
],
'customer' => [ 'customer' => [
'new' => [ 'new' => [
'dear' => ':customer_name عزیز', 'dear' => ':customer_name عزیز',

View File

@ -643,6 +643,13 @@ return [
'thanks' => 'Grazie!' 'thanks' => 'Grazie!'
], ],
'update-password' => [
'subject' => 'Password aggiornata',
'dear' => 'Cara :name',
'info' => 'Ricevi questa email perché hai aggiornato la password.',
'thanks' => 'Grazie!'
],
'customer' => [ 'customer' => [
'new' => [ 'new' => [
'dear' => 'Gentile :customer_name', 'dear' => 'Gentile :customer_name',
@ -675,7 +682,7 @@ return [
'subject' => 'Email Iscrizione', 'subject' => 'Email Iscrizione',
'greeting' => ' Benvenuto ' . config('app.name') . ' - Email Iscrizione', 'greeting' => ' Benvenuto ' . config('app.name') . ' - Email Iscrizione',
'unsubscribe' => 'Cancellati', 'unsubscribe' => 'Cancellati',
'summary' => 'Grazie per avere scelto di ricevere le nostre email. È passato un po\' di tempo da quando hai letto le email di ' . config('app.name') . '. Non è un nostro desidero inondare la tua casella email con le nostre comunicazioni. Se desideri comunque 'summary' => 'Grazie per avere scelto di ricevere le nostre email. È passato un po\' di tempo da quando hai letto le email di ' . config('app.name') . '. Non è un nostro desidero inondare la tua casella email con le nostre comunicazioni. Se desideri comunque
non ricevere più le nostre news clicca il bottone qui sotto.' non ricevere più le nostre news clicca il bottone qui sotto.'
] ]
] ]

View File

@ -574,6 +574,12 @@ return [
'final-summary' => 'Si no has solicitado cambiar de contraseña, ninguna acción es requerida por tu parte.', 'final-summary' => 'Si no has solicitado cambiar de contraseña, ninguna acción es requerida por tu parte.',
'thanks' => 'ありがとうございます。' 'thanks' => 'ありがとうございます。'
], ],
'update-password' => [
'subject' => 'パスワードが更新されました',
'dear' => '様 :name',
'info' => 'パスワードを更新したため、このメールをお送りしています。',
'thanks' => 'ありがとうございます。'
],
'customer' => [ 'customer' => [
'new' => [ 'new' => [
'dear' => '様 :customer_name', 'dear' => '様 :customer_name',

View File

@ -639,6 +639,13 @@ return [
'thanks' => 'Bedankt!' 'thanks' => 'Bedankt!'
], ],
'update-password' => [
'subject' => 'Wachtwoord bijgewerkt',
'dear' => 'Lieve :name',
'info' => 'Je ontvangt deze e-mail omdat je je wachtwoord hebt bijgewerkt.',
'thanks' => 'Bedankt!'
],
'customer' => [ 'customer' => [
'new' => [ 'new' => [
'dear' => 'Lieve :customer_name', 'dear' => 'Lieve :customer_name',

View File

@ -633,6 +633,13 @@ return [
'thanks' => 'Dzięki!' 'thanks' => 'Dzięki!'
], ],
'update-password' => [
'subject' => 'Hasło zaktualizowane',
'dear' => 'Drogi/a :name',
'info' => 'Otrzymujesz tę wiadomość e-mail, ponieważ zaktualizowałeś swoje hasło.',
'thanks' => 'Dzięki!'
],
'customer' => [ 'customer' => [
'new' => [ 'new' => [
'dear' => 'Drogi/a :customer_name', 'dear' => 'Drogi/a :customer_name',

View File

@ -607,6 +607,13 @@ return [
'thanks' => 'Obrigado!' 'thanks' => 'Obrigado!'
], ],
'update-password' => [
'subject' => 'Senha atualizada',
'dear' => 'Caro :name',
'info' => 'Você está recebendo este e-mail porque atualizou sua senha.',
'thanks' => 'Obrigado!'
],
'customer' => [ 'customer' => [
'new' => [ 'new' => [
'dear' => 'Caro :customer_name', 'dear' => 'Caro :customer_name',

View File

@ -574,7 +574,7 @@ return [
'final-summary' => 'Bizi tercih ettiğiniz için teşekkür ederiz. Ürün kargoya teslim edildikten sonra takip numarası iletilecektir.', 'final-summary' => 'Bizi tercih ettiğiniz için teşekkür ederiz. Ürün kargoya teslim edildikten sonra takip numarası iletilecektir.',
'help' => 'Soru ve görüşleriniz için lütfen bizimle iletişime geçiniz: :support_email', 'help' => 'Soru ve görüşleriniz için lütfen bizimle iletişime geçiniz: :support_email',
'thanks' => 'Teşekkürler!', 'thanks' => 'Teşekkürler!',
'comment' => [ 'comment' => [
'subject' => 'Siparişinize yeni yorum yapıldı.', 'subject' => 'Siparişinize yeni yorum yapıldı.',
'dear' => 'Sayın :customer_name', 'dear' => 'Sayın :customer_name',
@ -639,6 +639,13 @@ return [
'thanks' => 'Teşekkürler!' 'thanks' => 'Teşekkürler!'
], ],
'update-password' => [
'subject' => 'Şifre güncellendi',
'dear' => 'Sayın :name',
'info' => 'Bu e-postayı, şifrenizi güncellediğiniz için alıyorsunuz.',
'thanks' => 'Teşekkürler!'
],
'customer' => [ 'customer' => [
'new' => [ 'new' => [
'dear' => 'Sayın :customer_name', 'dear' => 'Sayın :customer_name',

View File

@ -0,0 +1,25 @@
@component('shop::emails.layouts.master')
<div style="text-align: center;">
<a href="{{ config('app.url') }}">
@if (core()->getConfigData('general.design.admin_logo.logo_image'))
<img src="{{ \Illuminate\Support\Facades\Storage::url(core()->getConfigData('general.design.admin_logo.logo_image')) }}" alt="{{ config('app.name') }}" style="height: 40px; width: 110px;"/>
@else
<img src="{{ asset('vendor/webkul/ui/assets/images/logo.png') }}" alt="{{ config('app.name') }}"/>
@endif
</a>
</div>
<div style="padding: 30px;">
<p style="font-size: 16px;color: #5E5E5E;line-height: 24px;">
{{ __('shop::app.mail.update-password.dear', ['name' => $user->name]) }},
</p>
<p style="font-size: 16px;color: #5E5E5E;line-height: 24px;">
{{ __('shop::app.mail.update-password.info') }}
</p>
<p style="font-size: 16px;color: #5E5E5E;line-height: 24px;">
{{ __('shop::app.mail.update-password.thanks') }}
</p>
</div>
@endcomponent

View File

@ -0,0 +1,21 @@
@component('shop::emails.layouts.master')
<div style="text-align: center;">
<a href="{{ config('app.url') }}">
@include ('shop::emails.layouts.logo')
</a>
</div>
<div style="padding: 30px;">
<p style="font-size: 16px;color: #5E5E5E;line-height: 24px;">
{{ __('shop::app.mail.update-password.dear', ['name' => $user->name]) }},
</p>
<p style="font-size: 16px;color: #5E5E5E;line-height: 24px;">
{{ __('shop::app.mail.update-password.info') }}
</p>
<p style="font-size: 16px;color: #5E5E5E;line-height: 24px;">
{{ __('shop::app.mail.update-password.thanks') }}
</p>
</div>
@endcomponent

View File

@ -2,12 +2,12 @@
namespace Webkul\User\Http\Controllers; namespace Webkul\User\Http\Controllers;
use Hash;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Event;
use Webkul\User\Repositories\AdminRepository;
use Webkul\User\Repositories\RoleRepository;
use Webkul\User\Http\Requests\UserForm; use Webkul\User\Http\Requests\UserForm;
use Hash; use Webkul\User\Repositories\RoleRepository;
use Webkul\User\Repositories\AdminRepository;
class UserController extends Controller class UserController extends Controller
{ {
@ -125,11 +125,14 @@ class UserController extends Controller
*/ */
public function update(UserForm $request, $id) public function update(UserForm $request, $id)
{ {
$isPasswordChanged = false;
$data = $request->all(); $data = $request->all();
if (! $data['password']) { if (! $data['password']) {
unset($data['password']); unset($data['password']);
} else { } else {
$isPasswordChanged = true;
$data['password'] = bcrypt($data['password']); $data['password'] = bcrypt($data['password']);
} }
@ -143,6 +146,10 @@ class UserController extends Controller
$admin = $this->adminRepository->update($data, $id); $admin = $this->adminRepository->update($data, $id);
if ($isPasswordChanged) {
Event::dispatch('user.admin.update-password', $admin);
}
Event::dispatch('user.admin.update.after', $admin); Event::dispatch('user.admin.update.after', $admin);
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'User'])); session()->flash('success', trans('admin::app.response.update-success', ['name' => 'User']));

View File

@ -0,0 +1,43 @@
<?php
namespace Webkul\User\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class AdminUpdatePassword extends Mailable
{
use Queueable, SerializesModels;
/**
* The admin instance.
*
* @var \Webkul\User\Contracts\Admin $admin
*/
public $admin;
/**
* Create a new message instance.
*
* @param \Webkul\User\Contracts\Admin $admin
* @return void
*/
public function __construct($admin)
{
$this->admin = $admin;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($this->admin->email, $this->admin->name)
->subject(trans('shop::app.mail.update-password.subject'))
->view('shop::emails.admin.update-password', ['user' => $this->admin]);
}
}