更新模型上的laravel jenssegers mongodb类型转换不起作用相同值

问题描述

更新相同值的模型转换不适用于以下解决方案:

protected $casts =[
           'age' => 'integer'
];

public function setAgeAttribute()
{
    $this->attributes['age'] =  (int) $this->attributes['age'];
}

 and in controller 

 request()->validate([
        'name' => 'required','detail' => 'required','age' => 'required',]);

    $book->update($request->all());

现在当更改年龄值时,然后转换有效,但需要解决相同的值才能在那里但将类型更改为整数

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)