为了账号安全,请及时绑定邮箱和手机立即绑定

Call to a member function format() on string 乍回事?

$student= Student::find(1006); $student->name = 'kitty'; $student->age=18; $bool=  $student->save(); var_dump($bool); "Call to a member function format() on string" 更新不了数据怎么回事?

正在回答

3 回答

在模型里加上这个就好了

public function fromDateTime($val){

    return empty($val)?$val:$this->getDateFormat() ;

}


0 回复 有任何疑惑可以回复我~

需要将模型中asDateTime()
这个方法屏蔽了

4 回复 有任何疑惑可以回复我~

是否开了 public $timestamps = true; 自动更新时间的属性,如果开了,检查一下数据库中的created_at和updated_at,看提示应该是格式不符  "试图在字符串成员调用format()方法"

1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

Call to a member function format() on string 乍回事?

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号