我需要在我的数据库中存储一个过期日期,以检查他/她尝试登录时用户帐户是否仍然有效。
这是我的用户模型:
class User extends Model implements AuthenticatableContract, CanResetPasswordContract {
use Authenticatable, CanResetPassword;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
protected $dates = [
'expiration_date'
];
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'first_name',
'last_name',
'email',
'password',
'expiration_date'
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
'password',
'remember_token'
];
/**
* Questa funzione fa in modo di criptare in automatico la password quando si crea un utente
*
* @param $password
*
* @return string
*/
public function setPAsswordAttribute( $password )
{
return $this->attributes['password'] = bcrypt( $password );
}
public function setExpirationDateAttribute( $expiration )
{
return $this->attributes['expiration_date'] = Carbon::createFromDate('Y-m-d', $expiration);
}
}
在我的表单中,我有一个使用 datepicker 设置dd/mm/yyyy
格式的文本输入。
当我在数据库中按提交时,我只得到0000-00-00 00:00:00
问题是什么?