ldc-legaulois/app/Notifications/Customer/VerifyEmail.php
2026-10-19 15:49:33 +02:00

81 lines
2.8 KiB
PHP

<?php
namespace App\Notifications\Customer;
use Illuminate\Auth\Notifications\VerifyEmail as NotificationsVerifyEmail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\URL;
use Symfony\Component\Mime\Email;
class VerifyEmail extends NotificationsVerifyEmail implements ShouldQueue
{
use Queueable;
public $tries = 3;
/**
* The customer firstname.
*
* @var string
*/
protected $firstname;
/**
* Verify email.
*
* @return void
*/
public function __construct(string $firstname)
{
$this->firstname = $firstname;
static::$createUrlCallback = function ($notifiable) {
return \url(URL::temporarySignedRoute(
'club.verification.verify',
Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)),
[
'id' => $notifiable->getKey(),
'hash' => sha1($notifiable->getEmailForVerification()),
],
true
));
};
}
/**
* Build the mail representation of the notification.
*
* @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
*/
public function toMail(mixed $notifiable): MailMessage
{
// phpcs:enable
/** @var string $verificationUrl */
$verificationUrl = $this->verificationUrl($notifiable);
return (new MailMessage())
->view([
'html' => 'notifications::email-club',
'text' => 'notifications::email-club-text',
])
->subject(trans('Validation de votre compte - :site_name', ['site_name' => config('app.name')]))
->greeting(trans('Bonjour :name,', ['name' => $this->firstname]))
->line(trans(
"Vous venez de créer un compte :strong sur le Club des Gaulois : :endStrong quelle bonne idée pour bénéficier de la Bourse aux échanges Départ'aimants et profitez des bons de réduction à imprimer !",
[
'strong' => '<strong>',
'endStrong' => '</strong>',
]
))
->line('Vous pouvez également enregistrer vos recettes favorites et les commenter et faire une liste de courses avec vos produits Le Gaulois préféré.')
->line('Pour confirmer votre inscription, merci de cliquer sur le lien ci-dessous (lien valable 1h uniquement) :')
->action(trans('Confirmer mon adresse mail'), $verificationUrl)
->withSymfonyMessage(function (Email $message) {
$message->html($message->getHtmlBody(), 'utf-8');
});
}
}