Ravi Ravi - 5 months ago 76x
PHP Question

In Laravel 5, How to customize Session flash message with href

I'm showing Please verify your email before login in my login blade if user didn't verify his account through email link.

if ($user->is_verified == 0) {
$request->session()->flash("failed", "Please verify your email before login );
return redirect('/login');

And in my blade I do like this to catch it

@if (Session::has('failed'))
<div class="alert alert-danger">

But Now I have to add this message Please verify your email before login or resend the verification email and make resend part with href to a route. Any ideas ?


Use this code

In route.php add a route

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

In VerificationMailController.php

public function resend(){
     //do your resend verification mail code

Than use this code where you want to show resend message

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');