目前,我正在使用 MySQL 数据库开发 laravel 6。所以我想获取具有许多关系的记录。获取多个 id 的训练强度记录——见图片TrainingGoalModel.php/** * training_intensity_details => get multiple intensity with current goal * * @return void */public function training_intensity_details(){ return $this->hasMany(TrainingIntensity::class, 'id', 'training_intensity_ids');}目标控制器$query = $query->with('training_intensity_details')->get();, 两者都适用,$query = $query->with(['training_intensity_details'])->get();但是,关系不适用。请帮我。
1 回答
隔江千里
TA贡献1906条经验 获得超10个赞
尝试..
public function training_intensity_details()
{
return $this->hasMany(TrainingIntensity::class, 'training_intensity_ids', 'id');
}
- 1 回答
- 0 关注
- 108 浏览
添加回答
举报
0/150
提交
取消