我有两张桌子 - 联系和访问:
联系表
id | name
----- | -------
1 | Joe
2 | Sally
Run Code Online (Sandbox Code Playgroud)
访问表
id | contact_id | pathname | referrer
----- | ------- | ------- | -------
1 | 1 | about | google
2 | 1 | pricing | null
3 | 1 | signup | null
4 | 2 | about | null
5 | 2 | signup | null
Run Code Online (Sandbox Code Playgroud)
使用eloquent,我想检索所有具有路径名 ='注册'和引用者 ='谷歌'的联系人.
到目前为止我得到的是:
Contact::whereHas('visits', function($query) {
$query->where('pathname','=','signup');
})
->orWhereHas('visits', …Run Code Online (Sandbox Code Playgroud)