种子错误:DateTime类的对象不能转换为字符串



我正在用laravel播种我的数据库,但我得到这个错误。要删除它,我需要注释模型的mutator部分

public function setBirthdayAttribute($value)
{   
$this->attributes['birthday'] = Carbon::createFromFormat('d-m-Y',$value)->format('Y-m-d');
}
public function setFirstHireAttribute($value)
{
$this->attributes['first_hire'] = Carbon::createFromFormat('d-m-Y',$value)->format('Y-m-d');
}

我该如何修复它?我快要疯了

谢谢Valerio

试试这个

public function setBirthdayAttribute($value)
{   
$this->attributes['birthday'] = date('Y-m-d',strtotime($value));
}
public function setFirstHireAttribute($value)
{
$this->attributes['first_hire'] = date('Y-m-d',strtotime($value));
}

最新更新