伙计我首先有2个表是 users 第二个是 notes :
我用 Many to many relationship 连接两个表
users,notes和user_note表
现在我试图登录用户注释,我已经通过 Auth::user() -> id
登录用户ID,我也试图获得 all the other users ,可以看到相同的注释 .
例如
user_id=1 可以看到 note_id=2 也 user_id=2 可以看到 note_id=2 .
所以 note_id=2 有 2 users .
问题:
我想雄辩,让我所有登录用户的笔记和其他共享相同笔记的用户 .
我试过 whereHas
但是我无法得到我需要的东西 .
1 回答
试试这个: