Php 在hasManyThrough关系之后附加另一个表
我正在尝试将4个表连接在一起:Php 在hasManyThrough关系之后附加另一个表,php,laravel,Php,Laravel,我正在尝试将4个表连接在一起: StepAnimation Model: public function steps() { return $this->hasManyThrough('App\Models\Step','App\Models\WorkSequence'); } public function step() { return $this->belongsTo('App\Models\Step');
StepAnimation Model:
public function steps()
{
return $this->hasManyThrough('App\Models\Step','App\Models\WorkSequence');
}
public function step()
{
return $this->belongsTo('App\Models\Step');
}
Step Model:
public function workSequence()
{
return $this->belongsTo('App\Models\WorkSequence');
}
public function stepAnimation()
{
return $this->hasMany('App\Models\StepAnimation');
}
WorkSequence Model:
public function categoryWorkSequence()
{
return $this->hasMany('App\Models\CategoryWorkSequence');
}
public function step()
{
return $this->hasMany('App\Models\Step');
}
CategoryWorkSequence Model:
public function workSequence()
{
return $this->belongsTo('App\Models\WorkSequence');
}
我当前正在选择具有步骤动画的所有工作序列:
$this->stepAnimation = New StepAnimation();
$workSequence = $this->stepAnimation::with('step.workSequence')->get();
但是现在我想将所有类别附加到工作序列,我需要如何扩展“选择”以实现这一点?然后您可以继续选择工作序列中的类别关系,只要它在您的模型上可用。像这样
$this->stepAnimation = New StepAnimation();
$workSequence = $this->stepAnimation::with('step.workSequence.categoryWorkSequence')->get();