这是我的解决方案。我在模型类中写了这个。 (评分是字符串类型)
$code = (int)$ratings;
但我需要在从数据库检索 $ ratings 时更改它。
我该怎么做?
我们有一个模型的属性称为cast
您可以在其中指定列名称,如下所示:
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'ratings' => 'integer',
];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)