Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在Laravel 5中,如何使用href自定义会话flash消息_Php_Session_Laravel 5.1 - Fatal编程技术网

Php 在Laravel 5中,如何使用href自定义会话flash消息

Php 在Laravel 5中,如何使用href自定义会话flash消息,php,session,laravel-5.1,Php,Session,Laravel 5.1,我正在显示如果用户未通过电子邮件链接验证其帐户,请在登录前在我的登录页面中验证您的电子邮件 if ($user->is_verified == 0) { $request->session()->flash("failed", "Please verify your email before login ); return redirect('/login'); } 在我的刀刃上,我喜欢这样来抓住它 @if (Session::has('failed'))

我正在显示如果用户未通过电子邮件链接验证其帐户,请在登录前在我的登录页面中验证您的电子邮件

if ($user->is_verified == 0) {
    $request->session()->flash("failed", "Please verify your email before login );
    return redirect('/login');
}
在我的刀刃上,我喜欢这样来抓住它

@if (Session::has('failed'))
    <div class="alert alert-danger">
    {{Session::get('failed')}}.<br><br>
    </div>              
@endif
@if(Session::has('failed'))
{{Session::get('failed')}。

@恩迪夫
但是现在我必须添加此消息请在登录前验证您的电子邮件,或者重新发送验证电子邮件,并使用href将重新发送部分发送到路由。有什么想法吗?

使用此代码

在route.php中添加一个路由

Route::get('/resend_mail', 'VerificationMailController@resend'); //replace with your desired location
在VerificationMailController.php中

public function resend(){
     //do your resend verification mail code
}
然后在要显示重发消息的位置使用此代码

if ($user->is_verified == 0) {
$resendurl = route('resend_mail'); //here replace the route of your email verification send route.
$msg = 'Please verify your email before login or <a href="'.$resendurl.'">resend</a> the verification email';
    $request->session()->flash("failed",  $msg);
    return redirect('/login');
}
如果($user->已验证==0){
$resendurl=route('ressend_mail');//此处替换电子邮件验证发送路由的路由。
$msg='请在登录前验证您的电子邮件或验证电子邮件';
$request->session()->flash(“失败”,$msg);
返回重定向('/login');
}
使用此代码

在route.php中添加一个路由

Route::get('/resend_mail', 'VerificationMailController@resend'); //replace with your desired location
在VerificationMailController.php中

public function resend(){
     //do your resend verification mail code
}
然后在要显示重发消息的位置使用此代码

if ($user->is_verified == 0) {
$resendurl = route('resend_mail'); //here replace the route of your email verification send route.
$msg = 'Please verify your email before login or <a href="'.$resendurl.'">resend</a> the verification email';
    $request->session()->flash("failed",  $msg);
    return redirect('/login');
}
如果($user->已验证==0){
$resendurl=route('ressend_mail');//此处替换电子邮件验证发送路由的路由。
$msg='请在登录前验证您的电子邮件或验证电子邮件';
$request->session()->flash(“失败”,$msg);
返回重定向('/login');
}

最后,我对代码做了一些小改动

我在blade中的代码应该这样更改。因为否则它将不接受html语法,只显示计划html。这就是所谓的

@if(Session::has('failed'))
{!!Session::get('failed')!!}。

@恩迪夫
答案是正确的。但考虑到我的问题,我像这样修改了他的代码

if ($user->is_verified == 0) {                    
     $msg = 'Please verify your email before login or <a href="'. url("/resend_email").'">resend</a> the verification email';
     $request->session()->flash("failed",  $msg);
     return redirect('/login');
 }
如果($user->已验证==0){
$msg='请在登录前验证您的电子邮件或验证电子邮件';
$request->session()->flash(“失败”,$msg);
返回重定向('/login');
}
现在我想要的就是这样


最后,我对代码做了一些小改动

我在blade中的代码应该这样更改。因为否则它将不接受html语法,只显示计划html。这就是所谓的

@if(Session::has('failed'))
{!!Session::get('failed')!!}。

@恩迪夫
答案是正确的。但考虑到我的问题,我像这样修改了他的代码

if ($user->is_verified == 0) {                    
     $msg = 'Please verify your email before login or <a href="'. url("/resend_email").'">resend</a> the verification email';
     $request->session()->flash("failed",  $msg);
     return redirect('/login');
 }
如果($user->已验证==0){
$msg='请在登录前验证您的电子邮件或验证电子邮件';
$request->session()->flash(“失败”,$msg);
返回重定向('/login');
}
现在我想要的就是这样


没有。。我已经做了。如果用户不小心删除了他的验证电子邮件,他将无法登录到他的帐户。有时他忘了核实。因此,在该消息中,我必须以何种格式重新发送它,我应该在那里给出url。例如:-我的路线是/重发邮件请查看更新的代码。我认为现在你应该知道如何处理它,但我认为是这样的,请在登录前验证你的电子邮件或验证电子邮件。不不。。我已经做了。如果用户不小心删除了他的验证电子邮件,他将无法登录到他的帐户。有时他忘了核实。因此,在该消息中,我必须以何种格式重新发送它,我应该在那里给出url。例如:-我的路线是/重发邮件请查看更新的代码。我认为现在你应该知道如何处理它,但我看到它像这样,请验证您的电子邮件之前登录或验证电子邮件。