new funcionality
This commit is contained in:
43
app/Notifications/ResetPasswordNotification.php
Normal file
43
app/Notifications/ResetPasswordNotification.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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\App;
|
||||
|
||||
class ResetPasswordNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(public readonly string $token, private readonly string $emailLocale)
|
||||
{
|
||||
}
|
||||
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
// Seteamos el locale de la app explícitamente antes de construir los
|
||||
// strings: los __() de acá abajo salen en el idioma de la sesión que
|
||||
// pidió el reset (no el locale por defecto del worker de la cola).
|
||||
App::setLocale($this->emailLocale);
|
||||
|
||||
$url = url('/reset-password').'?'.http_build_query([
|
||||
'token' => $this->token,
|
||||
'email' => $notifiable->getEmailForPasswordReset(),
|
||||
]);
|
||||
|
||||
return (new MailMessage)
|
||||
->subject(__('messages.reset_password_subject'))
|
||||
->line(__('messages.reset_password_intro'))
|
||||
->action(__('messages.reset_password_action'), $url)
|
||||
->line(__('messages.reset_password_expire', ['count' => config('auth.passwords.users.expire')]))
|
||||
->line(__('messages.reset_password_no_action'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user