【发布时间】:2018-06-07 03:38:31
【问题描述】:
我正在使用 octobercms 插件,其中包含以下模型:
- 房屋
- 支付
- 所有者
在房屋模型中,我有以下关系:
public $hasManyThrough = [
'owner' => [
'Author\Plugin\Models\Owner',
'table' => 'author_plugin_houses_owners',
'key' => 'houses_id',
'otherKey' => 'owners_id'
]
];
这个关系有一个中间表'author_plugin_houses_owners':
+------------+-------------+--------+
| hoses_id | owners_id | active |
+------------+-------------+--------+
在支付模型中,我有以下关系:
public $belongsTo = [
'houses' => ['Author\Plugin\Models\Houses']
];
这个模型对应的表格是这样的:
+----+----------+---------+-------+------+
| id | hoses_id | amounth | payed | debt |
+----+----------+---------+-------+------+
在表中我有一列“houses_id”,问题是,我如何访问“Houses”模型中声明的“所有者”关系,因为“Pays”模型?我需要访问它,因为我需要在插件后端的列表视图中打印“owner_name”。
所有者表:
+----+------------+--------+
| id | owner_name | active |
+----+------------+--------+
非常感谢!
【问题讨论】:
标签: php laravel octobercms