Last active
March 2, 2021 10:10
-
-
Save leeliwei930/b437d298aa3eab1bae858d516d7050b2 to your computer and use it in GitHub Desktop.
Override Laravel Verification Email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use App\Notifications\VerifyEmail; | |
public function sendEmailVerificationNotification() | |
{ | |
$this->notify(new VerifyEmail($this->email)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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