In deed the options is not there in Laravel, but since laravel makes use of the following:
In the MustVerifyEmail
trait, there's a method called sendEmailVerificationNotification
. This is where the Notification VerifyEmail
class referenced by @nakov's answer and its function verificationUrl
is used:
/**
* Send the email verification notification.
*
* @return void
*/
public function sendEmailVerificationNotification()
{
$this->notify(new Notifications\VerifyEmail);
}
Since we know this, we can do the following:
- Extend the
Notifications\VerifyEmail
to our custom VerifyEmail
class
- override the implementation of
verificationUrl
- override the implementation of the
sendEmailVerificationNotification
method in the User
model to use our new VerifyEmail
class.
Having done the above, our User
model will have the following method:
/**
* Send the email verification notification.
*
* @return void
*/
public function sendEmailVerificationNotification()
{
$this->notify(new \App\Services\Verification\VerifyEmail);
}
Now we make use of our custom VerifyEmail
class. Then our new VerifyEmail
class would look like this:
namespace App\Services\Verification;
use Illuminate\Support\Carbon;
use \Illuminate\Support\Facades\URL;
class VerifyEmail extends \Illuminate\Auth\Notifications\VerifyEmail
{
protected function verificationUrl($notifiable)
{
return URL::temporarySignedRoute(
'verification.verify', Carbon::now()->addMinute(3), ['id' => $notifiable->getKey()]
); //we use 3 minutes expiry
}
}
Well, apart from the explanations, the process is quite straight forward. I hope it is easy to grasp. Cheers!