Steps:
- Create the MySQL database and write the credentials inside the .env file.
- php artisan migrate
- php artisan make:auth
- In the User.php model, you can see one more contract added called MustVerifyEmail
- Add Email Route Verification
- Auth::routes(['verify' => true]);
- Also, we need to protect the HomeController route, so let us do that via adding middleware.
- public function __construct()
- {
-
$this->middleware(['auth', 'verified']);
- }
- Setup email configuration
- MAIL_DRIVER=smtp
- MAIL_HOST=smtp.mailtrap.io
- MAIL_PORT=2525
- MAIL_USERNAME=null
- MAIL_PASSWORD=null
- MAIL_ENCRYPTION=null
- Test the email verification:
- Check the Email and Click on the link
- To verify check the database also and see value of email_verified_at
Laravel is accessible, powerful, and provides tools required for large, robust applications.
The Laravel framework is open-source software licensed under the MIT license.