如何在users.sport_id
中存储数据:
用户类别:
public function sport() {
return $this->belongsToMany('App\Sport');
}
运动桌所在的位置:
+----+------------+
| id | sport |
+----+------------+
| 1 | baseball |
+----+------------+
| 2 | basketball |
+----+------------+
我要添加到user.sport_id = 1,2
还是将其保存为数组[1,2]
并使用$casts = ['sport_id'=>'array'];