Today, Laravel is a most popular PHP framework and laravel provides us many many very helpful functionality in-built. it's making our web development very easy.

We will share with you in this article how to make user email verification and account activation functionality in laravel 6 applications. Many web application needs to verify user email before they start to use application. Laravel provides convenient methods for sending and verifying email verification requests.

Here we will show you how to use email verification in laravel application

Step - 1 Create Laravel Application.

First, we need to create one fresh laravel project using the following composer command. if you want to implement or use email verification functionality in the existing laravel 6 application then this does not need to do for you.

composer create-project --prefer-dist laravel/laravel blog

Step - 2 Create Migration.

After, create laravel project in your local system then you should be run migration by the following artisan command.

php artisan migrate

your users table must contain an email_verified_at column to store the date and time that the email address was verified. By default, the users table migration included with the Laravel framework already includes this column. So, all you need to do is run your database migrations:

Step - 3 Routing.

Laravel used Auth/VerificationController middleware class for check user email verifed or not. and you should be add the following route in your routes/web.php file.

Auth::routes(['verify' => true]);

# Protecting Routes

Route middleware can be used to only allow verified users to access a given route. Laravel ships with a verified middleware, which is defined at Illuminate\Auth\Middleware\EnsureEmailIsVerified. Since this middleware is already registered in your application's HTTP kernel, all you need to do is attach the middleware to a route definition:

Route::get('edit-profile', function () {
    // Only verified users may enter...
})->middleware('verified');

Step - 4 Generate Views.

Into the last we need to generate mail templates view, laravel provide ready made mail view. you can generate it help of the run the following command in your terminal.

composer require laravel/ui --dev

php artisan ui vue --auth

After, run the above all required mails templates automatically generated in this path resources/views/auth/

Conclusion

As you can see, user email verification functionality is very easy to use in laravel application help of Auth::routes.

We hope these tutorials help everyone. if you have any issues or question reagarding user email verification in laravel application. so, please comment bellow. Thanks..


Was this article helpful?

0 out of 0 person found this article helpful.

Leave a comment

OR

No Comments