PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, March 9, 2022

[FIXED] Customize email_verified_at column in laravel

 March 09, 2022     laravel, php     No comments   

Issue

I am currently working on a laravel project that needs to send a verification email. I successfully send an email but when I try to verify the email by clicking "Verify email address" button in the email it shows me the error unknown column "email_verified_at". I don't have rights to add or edit fields in the database. I am just wondering where can I change this field to something else? like instead of email_verified_at I'll use emailVerifiedAt


Solution

If you have changed the email_verified_at column name to something else you can try this

By default laravel User model extends Illuminate\Foundation\Auth\User and this class is using a trit named Illuminate\Auth\MustVerifyEmail which contains all the logic for verifying email address. So you can override the methods of trait inside User Model

Inside the User.php model

/**
     * Determine if the user has verified their email address.
     *
     * @return bool
     */
    public function hasVerifiedEmail()
    {
        return ! is_null($this->emailVerifiedAt);
    }

    /**
     * Mark the given user's email as verified.
     *
     * @return bool
     */
    public function markEmailAsVerified()
    {
        return $this->forceFill([
            'emailVerifiedAt' => $this->freshTimestamp(),
        ])->save();
    }


Answered By - ManojKiran Appathurai
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing