【发布时间】:2020-03-30 20:47:46
【问题描述】:
总结
我正在尝试使用hasManyThrough 关系与来自不同连接的表。
问题描述:
定义hasManyThrough 关系时,protected $connection 属性将被忽略。
复制步骤:
创建以下模型(缩写代码)
class Resource extends Model
{
protected $connection = 'tcollect'
public function absences()
{
return $this->hasManyThrough('ARM\TargetHoraire\Absence', 'ARM\Tcollect\ICO\ICOExternalReference', 'RecordID', 'ResourceID', 'ID', 'ExternalKey');
}
}
class Absence extends Model
{
protected $table = 'Absences';
protected $connection = 'punch';
}
class ICOExternalReference extends Model
{
protected $table = 'ICOExternalReferences';
protected $connection = 'tcollect';
}
然后调用资源模型上的关系
$resource->absences;
注意ICOExternalReference $connection 属性被忽略。它尝试使用来自punch 连接的ICOExternalReference。
问题
我的代码有什么问题吗?或者有没有办法解决这个问题? 我在框架 repo 上创建了一个问题,但它立即关闭了。
【问题讨论】: