Enahancement Done
This commit is contained in:
parent
e6d11ed809
commit
f05b17aa99
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,8 @@ class EventServiceProvider extends ServiceProvider
|
|||
*/
|
||||
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('sales.invoice.save.after', 'Webkul\Admin\Listeners\Order@sendNewInvoiceMail');
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ class CustomerController extends Controller
|
|||
*/
|
||||
public function update()
|
||||
{
|
||||
$isPasswordChanged = false;
|
||||
$id = auth()->guard('customer')->user()->id;
|
||||
|
||||
$this->validate(request(), [
|
||||
|
|
@ -104,6 +105,7 @@ class CustomerController extends Controller
|
|||
if (isset ($data['oldpassword'])) {
|
||||
if ($data['oldpassword'] != "" || $data['oldpassword'] != null) {
|
||||
if (Hash::check($data['oldpassword'], auth()->guard('customer')->user()->password)) {
|
||||
$isPasswordChanged = true;
|
||||
$data['password'] = bcrypt($data['password']);
|
||||
} else {
|
||||
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 ($isPasswordChanged) {
|
||||
Event::dispatch('user.admin.update-password', $customer);
|
||||
}
|
||||
|
||||
Event::dispatch('customer.update.after', $customer);
|
||||
|
||||
Session()->flash('success', trans('shop::app.customer.account.profile.edit-success'));
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
@ -635,6 +635,13 @@ return [
|
|||
'thanks' => 'شكرا!'
|
||||
],
|
||||
|
||||
'update-password' => [
|
||||
'subject' => 'تم تحديث كلمة السر',
|
||||
'dear' => ':name عزيزي',
|
||||
'info' => 'أنت تتلقى هذا البريد الإلكتروني لأنك قمت بتحديث كلمة المرور الخاصة بك.',
|
||||
'thanks' => 'شكرا!'
|
||||
],
|
||||
|
||||
'customer' => [
|
||||
'new' => [
|
||||
'dear' => ':customer_name العزيز',
|
||||
|
|
|
|||
|
|
@ -629,6 +629,13 @@ return [
|
|||
'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' => [
|
||||
'new' => [
|
||||
'dear' => 'Sehr geehrte/r :customer_name',
|
||||
|
|
|
|||
|
|
@ -644,6 +644,13 @@ return [
|
|||
'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' => [
|
||||
'new' => [
|
||||
'dear' => 'Dear :customer_name',
|
||||
|
|
|
|||
|
|
@ -582,6 +582,12 @@ return [
|
|||
'final-summary' => 'Si no has solicitado cambiar de contraseña, ninguna acción es requerida por tu parte.',
|
||||
'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' => [
|
||||
'new' => [
|
||||
'dear' => 'Estimado/a :customer_name',
|
||||
|
|
|
|||
|
|
@ -634,6 +634,13 @@ return [
|
|||
'thanks' => 'با تشکر'
|
||||
],
|
||||
|
||||
'update-password' => [
|
||||
'subject' => 'پسورد آپدیت شد',
|
||||
'dear' => ':name عزیز',
|
||||
'info' => 'شما این ایمیل را دریافت می کنید زیرا رمز خود را به روز کرده اید.',
|
||||
'thanks' => 'با تشکر'
|
||||
],
|
||||
|
||||
'customer' => [
|
||||
'new' => [
|
||||
'dear' => ':customer_name عزیز',
|
||||
|
|
|
|||
|
|
@ -643,6 +643,13 @@ return [
|
|||
'thanks' => 'Grazie!'
|
||||
],
|
||||
|
||||
'update-password' => [
|
||||
'subject' => 'Password aggiornata',
|
||||
'dear' => 'Cara :name',
|
||||
'info' => 'Ricevi questa email perché hai aggiornato la password.',
|
||||
'thanks' => 'Grazie!'
|
||||
],
|
||||
|
||||
'customer' => [
|
||||
'new' => [
|
||||
'dear' => 'Gentile :customer_name',
|
||||
|
|
@ -675,7 +682,7 @@ return [
|
|||
'subject' => 'Email Iscrizione',
|
||||
'greeting' => ' Benvenuto ' . config('app.name') . ' - Email Iscrizione',
|
||||
'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.'
|
||||
]
|
||||
]
|
||||
|
|
|
|||
|
|
@ -574,6 +574,12 @@ return [
|
|||
'final-summary' => 'Si no has solicitado cambiar de contraseña, ninguna acción es requerida por tu parte.',
|
||||
'thanks' => 'ありがとうございます。'
|
||||
],
|
||||
'update-password' => [
|
||||
'subject' => 'パスワードが更新されました',
|
||||
'dear' => '様 :name',
|
||||
'info' => 'パスワードを更新したため、このメールをお送りしています。',
|
||||
'thanks' => 'ありがとうございます。'
|
||||
],
|
||||
'customer' => [
|
||||
'new' => [
|
||||
'dear' => '様 :customer_name',
|
||||
|
|
|
|||
|
|
@ -639,6 +639,13 @@ return [
|
|||
'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' => [
|
||||
'new' => [
|
||||
'dear' => 'Lieve :customer_name',
|
||||
|
|
|
|||
|
|
@ -633,6 +633,13 @@ return [
|
|||
'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' => [
|
||||
'new' => [
|
||||
'dear' => 'Drogi/a :customer_name',
|
||||
|
|
|
|||
|
|
@ -607,6 +607,13 @@ return [
|
|||
'thanks' => 'Obrigado!'
|
||||
],
|
||||
|
||||
'update-password' => [
|
||||
'subject' => 'Senha atualizada',
|
||||
'dear' => 'Caro :name',
|
||||
'info' => 'Você está recebendo este e-mail porque atualizou sua senha.',
|
||||
'thanks' => 'Obrigado!'
|
||||
],
|
||||
|
||||
'customer' => [
|
||||
'new' => [
|
||||
'dear' => 'Caro :customer_name',
|
||||
|
|
|
|||
|
|
@ -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.',
|
||||
'help' => 'Soru ve görüşleriniz için lütfen bizimle iletişime geçiniz: :support_email',
|
||||
'thanks' => 'Teşekkürler!',
|
||||
|
||||
|
||||
'comment' => [
|
||||
'subject' => 'Siparişinize yeni yorum yapıldı.',
|
||||
'dear' => 'Sayın :customer_name',
|
||||
|
|
@ -639,6 +639,13 @@ return [
|
|||
'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' => [
|
||||
'new' => [
|
||||
'dear' => 'Sayın :customer_name',
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
namespace Webkul\User\Http\Controllers;
|
||||
|
||||
use Hash;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\User\Repositories\AdminRepository;
|
||||
use Webkul\User\Repositories\RoleRepository;
|
||||
use Webkul\User\Http\Requests\UserForm;
|
||||
use Hash;
|
||||
use Webkul\User\Repositories\RoleRepository;
|
||||
use Webkul\User\Repositories\AdminRepository;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
|
|
@ -125,11 +125,14 @@ class UserController extends Controller
|
|||
*/
|
||||
public function update(UserForm $request, $id)
|
||||
{
|
||||
$isPasswordChanged = false;
|
||||
|
||||
$data = $request->all();
|
||||
|
||||
if (! $data['password']) {
|
||||
unset($data['password']);
|
||||
} else {
|
||||
$isPasswordChanged = true;
|
||||
$data['password'] = bcrypt($data['password']);
|
||||
}
|
||||
|
||||
|
|
@ -143,6 +146,10 @@ class UserController extends Controller
|
|||
|
||||
$admin = $this->adminRepository->update($data, $id);
|
||||
|
||||
if ($isPasswordChanged) {
|
||||
Event::dispatch('user.admin.update-password', $admin);
|
||||
}
|
||||
|
||||
Event::dispatch('user.admin.update.after', $admin);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'User']));
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue