Laravel有很多通过不起作用

时间:2020-08-19 02:03:46

标签: php laravel postgresql

我的代码:

    public function users()
    {
        return $this->hasManyThrough(
            'App\Models\User',
            'App\Models\UserGroupDue',
            'user_id',
            'id',
            'name',
            'group_name'
        );
    }

错误: enter image description here

我的用户表:

enter image description here

我的用户将到期表分组:

enter image description here

我的群组表:

enter image description here

1 个答案:

答案 0 :(得分:0)

问题出在用户功能上

尝试

public function users()
{
    return $this->hasManyThrough(
        'App\Models\User',
        'App\Models\UserGroupDue',
        'user_id',
        'group_name'
        'id',
        'name',
    );
}