104 lines
2.5 KiB
PHP
104 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
use Illuminate\Support\Facades\Lang;
|
|
|
|
class UserPasswordResetNotification extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
/**
|
|
* The password reset token.
|
|
*
|
|
* @var string
|
|
*/
|
|
public $token;
|
|
|
|
/**
|
|
* The locale for the notification.
|
|
*
|
|
* @var string
|
|
*/
|
|
public $locale;
|
|
|
|
/**
|
|
* Create a new notification instance.
|
|
*
|
|
* @param string $token
|
|
* @param string|null $locale
|
|
* @return void
|
|
*/
|
|
public function __construct(string $token, string $locale = null)
|
|
{
|
|
$this->token = $token;
|
|
$this->locale = $locale ?? config('app.fallback_locale');
|
|
|
|
// Ensure locale is not empty
|
|
if (empty($this->locale)) {
|
|
$this->locale = config('app.fallback_locale');
|
|
}
|
|
|
|
$this->onQueue('high');
|
|
}
|
|
|
|
/**
|
|
* 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)
|
|
{
|
|
// Set application locale for this email
|
|
app()->setLocale($this->locale);
|
|
|
|
$resetUrl = url(route('password.reset', [
|
|
'token' => $this->token,
|
|
'email' => $notifiable->getEmailForPasswordReset(),
|
|
], false));
|
|
|
|
$subject = trans('Reset Password Notification', [], $this->locale);
|
|
$expireMinutes = config('auth.passwords.users.expire');
|
|
|
|
return (new MailMessage())
|
|
->from(timebank_config('mail.support.email'), timebank_config('mail.support.name'))
|
|
->subject($subject)
|
|
->view('emails.auth.reset-password', [
|
|
'notifiable' => $notifiable,
|
|
'resetUrl' => $resetUrl,
|
|
'subject' => $subject,
|
|
'expireMinutes' => $expireMinutes,
|
|
'locale' => $this->locale,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Get the array representation of the notification.
|
|
*
|
|
* @param mixed $notifiable
|
|
* @return array
|
|
*/
|
|
public function toArray($notifiable)
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
}
|