简体   繁体   中英

FOSUserbundle registration date

I have installed FOSUserbundle on my server and customized my frontend. Everything works fine. Now i'll add Register Date into my database. I have added this:

/**
* @ORM\Column(name="register_date", type="date")
*/
private $registerDate;

into entity User.php and after database update, this column was succesfully added into database. Now after registring, it should automatically add registration date into database. What should i change/add into my code so that it works? thanks for help!

Please add to User entity a constructor (or modify it, if already exists):

public function __construct()
{
    if (empty($this->registerDate)) {
        $this->registerDate = new \DateTime();
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM