Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.7 check if email is verified

How I can check if the email is verified in Laravel 5.7?

I think, that may be with:

if(!Auth::user()->email_verified_at) {
    return 'Email not verified!';
}

Or is there other methods?

like image 457
Dumitru Avatar asked Oct 19 '18 11:10

Dumitru


1 Answers

Instead of checking the column directly, you can use the method included with the User model:

$user->hasVerifiedEmail()

If you read the docs, you'll see Laravel also includes a middleware named 'verified' for limiting access to verified users.

like image 67
Devon Avatar answered Nov 11 '22 17:11

Devon