ldc-gen-game-web/app/Notifications/Customer/ResetPassword.php
noah.lancien 218a3a7891 phpstan
2024-01-31 09:03:18 +00:00

69 lines
2.2 KiB
PHP

<?php
namespace App\Notifications\Customer;
use App\Models\Settings;
use Illuminate\Auth\Notifications\ResetPassword as NotificationsResetPassword;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\URL;
class ResetPassword extends NotificationsResetPassword
{
/**
* The callback that should be used to create the reset password URL.
*
* @var (\Closure(mixed, string): string)|null
*/
public static $createUrlCallback;
/**
* ResetPassword
*
* @param string $token
* @return void
*/
public function __construct(string $token)
{
parent::__construct($token);
static::$createUrlCallback = function ($notifiable, $token) {
return \url(URL::temporarySignedRoute(
'fo.password.reset',
now()->addHours(24),
[
'token' => $token,
'email' => $notifiable->getEmailForPasswordReset(),
],
true
));
};
}
/**
* Build the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
* @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
*/
public function toMail($notifiable)
{
// phpcs:enable
/** @var \App\Models\Settings */
$settings = app(Settings::class);
/** @var \App\Models\Customer $notifiable */
$resetUrl = $this->resetUrl($notifiable);
/** @var string $first_name */
$first_name = $notifiable->api_data->firstname;
return (new MailMessage())
->subject(trans('Mot de passe oublié - :site_name', ['site_name' => $settings->name]))
->greeting(trans('Bonjour :first_name', ['first_name' => $first_name]))
->line(trans(
'Afin réinitialiser votre mot de passe pour vous connecter à :site_name, cliquez sur le lien suivant :',
['site_name' => $settings->name]
))
/** @var string $verificationUrl */
->action(trans('Réinitialisez votre mot de passe'), $resetUrl);
}
}