laravel - 如果未验证电子邮件,则显示一条消息 Laravel
问题描述
如果电子邮件经过验证,我需要做一些事情<p>
,如果可能的话,在主页上显示一些文本,而不是路线
@if(email is verified)
<p>hello there</p>
@endif
@else
<p>you need to verify your email address</p>
VerificationController.php
如果我设置了一个电子邮件版本,我是否需要创建一个控制器或更改当前的:
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\VerifiesEmails;
class VerificationController extends Controller
{
/*
|--------------------------------------------------------------------------
| Email Verification Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling email verification for any
| user that recently registered with the application. Emails may also
| be re-sent if the user didn't receive the original email message.
|
*/
use VerifiesEmails;
/**
* Where to redirect users after verification.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
}
解决方案
这取决于您如何知道用户已通过验证。如果您有一个用户的数据库列 email_verified_at 作为可为空的日期时间,您可以执行以下操作:
//The authenticated user is verified, since there is a datetime
@if(Auth::user()->email_verified_at != null)
//Do something
@else
//Do something else, since the authenticated user is not verified
@endif
推荐阅读
- xamarin - 有什么方法可以将 Application.Current.Properties 存储在数据库中,以便在多个设备之间共享这些?
- java - Play framework 2.6 Java 无法在新 Mac 上编译
- python - Python 应用迭代 linregress
- r - 如何在R中做嵌套饼图,其中外环数据是内环的子集?
- javascript - onclicking 一个内部 div 也 onclicks 外部 div
- javascript - VueJS 在嵌套的 v-for 循环中动态添加表单组件?
- aws-sdk - 如何估计 AWS Glue 和 Athena 的客户利用率
- angular - 角度找不到上传的图像
- python - 使用 Selenium 和 BeautifulSoup 通过提供表 ID Python3.7 不会返回特定表(返回空数组)
- html - 删除 ::after css 伪元素周围的边框/边距