Laravel 5.7 检查电子邮件是否经过验证

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/52891555/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:07:26  来源:igfitidea点击:

Laravel 5.7 check if email is verified

phplaravellaravel-5.7

提问by Dumitru

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

如何检查电子邮件是否在 Laravel 5.7 中得到验证?

I think, that may be with:

我认为,这可能与:

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

Or is there other methods?

或者还有其他方法吗?

回答by Devon

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

您可以使用 User 模型中包含的方法,而不是直接检查列:

$user->hasVerifiedEmail()

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

如果您阅读文档,您会看到 Laravel 还包含一个名为“已验证”的中间件,用于限制已验证用户的访问。

回答by reshma

Please refer this blog. You can add middleware for the same

请参考此博客。您可以为相同的内容添加中间件