模型中的 $casts 属性提供了一个便利的方法来将属性转换为常见的数据类型。$casts 属性应是一个数组,且数组的键是那些需要被转换的属性名称,值则是你希望转换的数据类型。支持转换的数据类型有: integer, real, float,double, decimal:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Software extends Model
{
protected $casts = [
‘software_ids‘ => ‘array‘,
];
}
?>
原文:https://www.cnblogs.com/caibaotimes/p/14490992.html