我有这个解决方案在 Laravel 5.3 中运行良好
$procedure = Procedure::findOrFail($id);
$attached_stages = $procedure->stages()->getRelatedIds()->toArray();
在我的Procedure
模型中:
public function stages()
{
return $this->belongsToMany('App\Models\Stage', 'procedure_stage', 'procedure_id', 'stage_id')->withPivot('id','status')->withTimestamps();
}
现在,在迁移到 Laravel 5.4 后,我收到了这个错误:
Call to undefined method Illuminate\Database\Query\Builder::getRelatedIds()
似乎getRelatedIds
已删除。
我的问题:
如何在 5.4 中获取数组?
先感谢您。