iPhone7Plus
iPhone7Plus

Reputation: 23

display a message if email is not verified Laravel

I need to do sth like if email is verified display a <p> with some text on the homepage, not with routes if it s possible

@if(email is verified)
<p>hello there</p>
@endif
@else
<p>you need to verify your email address</p>

Do I need to create a controller or make changes in current VerificationController.php if I have set up an email ver like:

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

Upvotes: 0

Views: 918

Answers (1)

Vimona
Vimona

Reputation: 345

It depends on how you know a user is verified. If you have a database column for users with email_verified_at as nullable datetime you can do something like this:

//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

Upvotes: 2

Related Questions