php - 使用 hasmanythrough 忽略 Laravel 连接属性
问题描述
概括
我正在尝试使用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 上创建了一个问题,但它立即关闭了。
解决方案
尝试
hasMany(class with all parameter)
推荐阅读
- r - 如何将 dplyr 操作与列名的字符串列表一起使用
- java - gremlin - 用作图形遍历初始化的最佳步骤
- android - 如果我在自定义视图中访问方法,应用程序崩溃
- javascript - 如何找到带有 JS 的网页声明?
- python - 纠正不完整的年份 - Python
- c# - 配置 IOptions
当 T 为 Type 时使用 ServiceCollection - delphi - 在我按下之前,在 stdinput 上读取的控制台应用程序不会返回
- c - C程序中的调用函数
- c# - 我在使用 FolderBrowserDialog 保存文件时遇到问题
- javascript - nodejs理解功能