Laravel 5.7 check if email is verified
Asked Answered
C

1

17

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?

Canning answered 19/10, 2018 at 11:33 Comment(1)
You can also check this with the verification middleware - laravel.com/docs/5.7/verificationTwiddle
T
41

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.

Tattletale answered 19/10, 2018 at 11:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.