Skip to content

Instantly share code, notes, and snippets.

@leeliwei930
Last active March 2, 2021 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leeliwei930/b437d298aa3eab1bae858d516d7050b2 to your computer and use it in GitHub Desktop.
Save leeliwei930/b437d298aa3eab1bae858d516d7050b2 to your computer and use it in GitHub Desktop.
Override Laravel Verification Email
<?php
use App\Notifications\VerifyEmail;
public function sendEmailVerificationNotification()
{
$this->notify(new VerifyEmail($this->email));
}
<?php
// make sure put it in app/notifications folder
namespace App\Notifications;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\URL;
class VerifyEmail extends \Illuminate\Auth\Notifications\VerifyEmail
{
private $email = "";
public function __construct($newEmail)
{
$this->email = $newEmail;
}
protected function verificationUrl($notifiable)
{
return URL::temporarySignedRoute(
'verification.verify',
Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)),
[
'id' => $notifiable->getKey(),
'hash' => sha1($notifiable->getEmailForVerification()),
'new_email' => $this->email
]
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment