Я сделал это, определив следующие отношения
В модели PostStageOneModel
public function assignedPost() {
return $this->belongsTo(Post::class, 'post_id', 'post_id');
}
public function assigner()
{
return $this->belongsTo(User::class, 'assigned_by', 'id');
}
public function assignee()
{
return $this->belongsTo(User::class, 'assigned_to', 'id');
}
В модели Post
public function identifiedBy() {
return $this->belongsTo(User::class, 'identified_by', 'id');
}
public function postAssignedBy() {
return $this->hasManyThrough(User::class, PostStageOneModel::class, 'post_id', 'id', 'post_id', 'assigned_by' );
}
public function postAssignedTo() {
return $this->hasManyThrough(User::class, PostStageOneModel::class, 'post_id', 'id', 'post_id', 'assigned_to' );
}
в модели пользователя
public function assigned()
{
return $this->hasMany(PostStageOneModel::class, 'assigned_by', 'id');
}
public function assignedTo()
{
return $this->hasMany(PostStageOneModel::class, 'assigned_to', 'id');
}