Laravel & Php

Laravel 5.7+ email verification


Laravel email verification

The Must Verify Email contract is a feature that allows you to send email verification in Laravel by adding a few lines of code to the following files:

App/User.php:

Implement the MustVerifyEmail contract in the User model:

<?php

namespace App;

use IlluminateNotificationsNotifiable;
use IlluminateContractsAuthMustVerifyEmail;
use IlluminateFoundationAuthUser as Authenticatable;

class User extends Authenticatable implements MustVerifyEmail
{
    use Notifiable;

    protected $fillable = [
        'name', 'email', 'password',
    ];

    protected $hidden = [
        'password', 'remember_token',
    ];
}

routes/web.php 

Add such routes as email/verify and email/resend to the app:

Route::get('/', function () {
    return view('welcome');</span>
});

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

Route::get('/home', 'HomeController@index')->name('home');

Laravel
Share with Friends

Like this chef? Share with friends..