skip to Main Content

I’m here to ask you a question for my Laravel 9 project if it’s possible please 🙂 !

I made an authentication with a user table. There is a column where you can check if the user verified his/her email or not. If he/she does, there is a datetime. If not, the column is null.

I would like to make a div in the profile section where there is an information for the user about the verification. If the verification is done, green information with the message "Good your email is verified", if not there is a red information with "Email not verified".

I tried this but it doesn’t work, it stays on "NOT VERIFIED" however there is a datetime in this session user.

Do you know why ? Or how can I fix it ?
Thanks a lot !

Code
Data structure

3

Answers


  1. Please try using this

    {{ auth()->user()->isVerified == null ? 'Not Verified' : 'Verified' }}
    
    Login or Signup to reply.
  2.  @if(Auth()->user()->isVerified)
           <div style="color:green">Good email is verified</div>
         @else
            <div style="color:red">Email not verified</div>
         @endif
    
    Login or Signup to reply.
  3. Try following

    @if(Auth::check())
      @if(Auth()->user()->isVerified)
        <div style='color:green'>Good your email is verified</div>
      @else
        <div style='color:red'>Email not verified</div>
      @endif
    @endif
    

    In Laravel there is a default method to determine if an email is verified or not. isVerified field is not necessary to check it.

    checkout this answer Laravel check if user email verified

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search